Volume 113

Fluid Mechanics and Its Applications

Series Editor

André Thess

Institute of Engineering Thermodynamics, German Aerospace Center, Stuttgart, Germany

Aims and Scope of the Series

The purpose of this series is to focus on subjects in which fluid mechanics plays a fundamental role.

As well as the more traditional applications of aeronautics, hydraulics, heat and mass transfer etc., books will be published dealing with topics which are currently in a state of rapid development, such as turbulence, suspensions and multiphase fluids, super and hypersonic flows and numerical modeling techniques.

It is a widely held view that it is the interdisciplinary subjects that will receive intense scientific attention, bringing them to the forefront of technological advancement. Fluids have the ability to transport matter and its properties as well as to transmit force, therefore fluid mechanics is a subject that is particularly open to cross fertilization with other sciences and disciplines of engineering. The subject of fluid mechanics will be highly relevant in domains such as chemical, metallurgical, biological and ecological engineering. This series is particularly open to such new multidisciplinary domains.

The median level of presentation is the first year graduate student. Some texts are monographs defining the current state of a field; others are accessible to final year undergraduates; but essentially the emphasis is on readability and clarity.

More information about this series at http://​www.​springer.​com/​series/​5980

F. Moukalled, L. Mangani and M. Darwish

The Finite Volume Method in Computational Fluid Dynamics An Advanced Introduction with OpenFOAM ® and Matlab ® 1st ed. 2015

F. Moukalled

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

L. Mangani

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

M. Darwish

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

ISSN 0926-5112e-ISSN 2215-0056

ISBN 978-3-319-16873-9e-ISBN 978-3-319-16874-6

DOI 10.1007/978-3-319-16874-6

Springer Cham Heidelberg New York Dordrecht London

Library of Congress Control Number: 2015939213

© Springer International Publishing Switzerland 2016

Additional material to this book can be downloaded from http://​extras.​springer.​com .

This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.

The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made.

Printed on acid-free paper

Springer International Publishing AG Switzerland is part of Springer Science+Business Media (www.springer.com)

Preface

The impetus to write this book came about from three sources:

The first source was the bi-yearly computational fluid dynamics (CFD) course, which has been offered over the last 15 years at the American University of Beirut (AUB) by both Drs. Darwish and Moukalled to senior and graduate mechanical engineering students, a course that focuses on the finite volume method (FVM) and CFD applications.

The second source grew over the years to become more significant as it was noticed that graduates have started working on increasingly more focused areas and topics in CFD while becoming less cognizant of the general algorithmic expertise that earlier students developed. It became clear that there is a need not only to cover the basis of the numerics at the core of CFD codes but also to discuss the implementation issues to ensure that all students receive a robust understanding of the techniques they are working on.

Finally, the collaborative work in advanced numerics with Prof. Dr. Mangani from HSLU, Lucerne, Switzerland, which started during the Ph.D. supervision of M. Buchmyer (Ph.D.) from TUGraz, provided all the incentive to clarify and detail much of the numerical basis of the algorithms used in OpenFOAM ® .

To this end, it was decided that the book would combine a mix of numerical and implementation details allowing the reader, if she/he desires, to fully understand and implement a robust and versatile CFD code based on the FVM.

This ambitious task was possible only by selecting from the various numerical methods in each of the topics covered in the book a handful set with which the authors are intimately familiar. The result is a book that covers intimately all the topics necessary for the development of a robust CFD code for the simulation of fluid flow at all speeds within the framework of the collocated unstructured finite volume method.

The book was also written with the classroom in mind as reflected by the use of copious illustrations; the provision of many exercises covering numerics, programming, and applications; the availability of an academic code (in MATLAB ® ) that imbeds much of the numerics presented in the book; and finally the various programs and routines in OpenFOAM ® .

The hope is that as you read through this book, you will share with us the excitement and intense interest that we have grown to have for this subject.

F. Moukalled

L. Mangani

M. Darwish

BeirutHorwBeirut

January 2015

Acknowledgments

It took nearly two years to complete this book, but much of what went in it was learned over a much longer period from interaction with numerous people in conferences and academic visits, from answering pertinent questions in our CFD courses and from our research work. However the enabler for all that is foremost the patience and kindness of our families.

We also wish to acknowledge the support provided to us by our respective institutions

American University of Beirut

Beirut, Lebanon

Lucerne University of Applied Science and Arts

Contents

Part I Foundation

1 Introduction 3

1.​1 What Is Computational Fluid Dynamics (CFD) 3

1.​2 What Is the Finite Volume Method 4

1.​3 This Book 5

1.​3.​1 Foundation 5

1.​3.​2 Numerics 6

1.​3.​3 Algorithms 7

1.​3.​4 Applications 8

1.​4 Closure 8

2 Review of Vector Calculus 9

2.​1 Introduction 9

2.​2 Vectors and Vector Operations 10

2.​2.​1 The Dot Product of Two Vectors 11

2.​2.​2 Vector Magnitude 11

2.​2.​3 The Unit Direction Vector 12

2.​2.​4 The Cross Product of Two Vectors 12

2.​2.​5 The Scalar Triple Product 14

2.​2.​6 Gradient of a Scalar and Directional Derivatives 15

2.​2.​7 Operations on the Nabla Operator 17

2.​2.​8 Additional Vector Operations 19

2.​3 Matrices and Matrix Operations 20

2.​3.​1 Square Matrices 21

2.​3.​2 Using Matrices to Describe Systems of Equations 23

2.​3.​3 The Determinant of a Square Matrix 23

2.​3.​4 Eigenvectors and Eigenvalues 26

2.​3.​5 A Symmetric Positive-Definite Matrix 27

2.​3.​6 Additional Matrix Operations 28

2.​4 Tensors and Tensor Operations 29

2.​5 Fundamental Theorems of Vector Calculus 32

2.​5.​1 Gradient Theorem for Line Integrals 32

2.​5.​2 Green’s Theorem 33

2.​5.​3 Stokes’ Theorem 34

2.​5.​4 Divergence Theorem 35

2.​5.​5 Leibniz Integral Rule 37

2.​6 Closure 38

2.​7 Exercises 39

References 41

3 Mathematical Description of Physical Phenomena 43

3.​1 Introduction 43

3.​2 Classification of Fluid Flows 44

3.​3 Eulerian and Lagrangian Description of Conservation Laws 45

3.​3.​1 Substantial Versus Local Derivative 46

3.​3.​2 Reynolds Transport Theorem 47

3.​4 Conservation of Mass (Continuity Equation) 48

3.​5 Conservation of Linear Momentum 50

3.​5.​1 Non-Conservative Form 51

3.​5.​2 Conservative Form 52

3.​5.​3 Surface Forces 52

3.​5.​4 Body Forces 54

3.​5.​5 Stress Tensor and the Momentum Equation for Newtonian Fluids 55

3.​6 Conservation of Energy 57

3.​6.​1 Conservation of Energy in Terms of Specific Internal Energy 60

3.​6.​2 Conservation of Energy in Terms of Specific Enthalpy 61

3.​6.​3 Conservation of Energy in Terms of Specific Total Enthalpy 61

3.​6.​4 Conservation of Energy in Terms of Temperature 62

3.​7 General Conservation Equation 65

3.​8 Non-dimensionalizati​on Procedure 67

3.​9 Dimensionless Numbers 72

3.​9.​1 Reynolds Number 72

3.​9.​2 Grashof Number 73

3.​9.​3 Prandtl Number 73

3.​9.​4 Péclet Number 75

3.​9.​5 Schmidt Number 75

3.​9.​6 Nusselt Number 77

3.​9.​7 Mach Number 77

3.​9.​8 Eckert Number 78

3.​9.​9 Froude Number 79

3.​9.​10 Weber Number 79

3.​10 Closure 80

3.​11 Exercises 80

References 82

4 The Discretization Process 85

4.​1 The Discretization Process 85

4.​1.​1 Step I:​ Geometric and Physical Modeling 87

4.​1.​2 Step II:​ Domain Discretization 88

4.​1.​3 Mesh Topology 90

4.​1.​4 Step III:​ Equation Discretization 93

4.​1.​5 Step IV:​ Solution of the Discretized Equations 98

4.​1.​6 Other Types of Fields 100

4.​2 Closure 101

5 The Finite Volume Method 103

5.​1 Introduction 103

5.​2 The Semi-Discretized Equation 104

5.​2.​1 Flux Integration Over Element Faces 105

5.​2.​2 Source Term Volume Integration 107

5.​2.​3 The Discrete Conservation Equation for One Integration Point 108

5.​2.​4 Flux Linearization 109

5.​3 Boundary Conditions 111

5.​3.​1 Value Specified (Dirichlet Boundary Condition) 111

5.​3.​2 Flux Specified (Neumann Boundary Condition) 112

5.​4 Order of Accuracy 113

5.​4.​1 Spatial Variation Approximation 113

5.​4.​2 Mean Value Approximation 114

5.​5 Transient Semi-Discretized Equation 117

5.​6 Properties of the Discretized Equations 118

5.​6.​1 Conservation 118

5.​6.​2 Accuracy 119

5.​6.​3 Convergence 119

5.​6.​4 Consistency 120

5.​6.​5 Stability 120

5.​6.​6 Economy 120

5.​6.​7 Transportiveness​ 120

5.​6.​8 Boundedness of the Interpolation Profile 121

5.​7 Variable Arrangement 122

5.​7.​1 Vertex-Centered FVM 123

5.​7.​2 Cell-Centered FVM 124

5.​8 Implicit Versus Explicit Numerical Methods 126

5.​9 The Mesh Support 127

5.​10 Computational Pointers 128

5.​10.​1 uFVM 128

5.10.2 OpenFOAM ® 129

5.​11 Closure 133

5.​12 Exercises 133

References 134

6 The Finite Volume Mesh 137

6.​1 Domain Discretization 137

6.​2 The Finite Volume Mesh 138

6.​2.​1 Mesh Support for Gradient Computation 139

6.​3 Structured Grids 142

6.​3.​1 Topological Information 142

6.​3.​2 Geometric Information 144

6.​3.​3 Accessing the Element Field 145

6.​4 Unstructured Grids 146

6.​4.​1 Topological Information (Connectivities) 147

6.​5 Geometric Quantities 152

6.​5.​1 Element Types 153

6.​5.​2 Computing Surface Area and Centroid of Faces 154

6.​6 Computational Pointers 162

6.​6.​1 uFVM 162

6.6.2 OpenFOAM ® 164

6.​7 Closure 170

6.​8 Exercises 170

References 170

7 The Finite Volume Mesh in OpenFOAM ® and uFVM 173

7.​1 uFVM 173

7.1.1 An OpenFOAM ® Test Case 173

7.​1.​2 The polyMesh Folder 175

7.​1.​3 The uFVM Mesh 178

7.​1.​4 uFVM Geometric Fields 183

7.​1.​5 Working with the uFVM Mesh 187

7.​1.​6 Computing the Gauss Gradient 188

7.2 OpenFOAM ® 191

7.​2.​1 Fields and Memory 197

7.​2.​2 InternalField Data 199

7.​2.​3 BoundaryField Data 200

7.​2.​4 lduAddressing 200

7.​2.​5 Computing the Gradient 202

7.​3 Mesh Conversion Tools 204

7.​4 Closure 205

7.​5 Exercises 205

References 207

Part II Discretization

8 Spatial Discretization:​ The Diffusion Term 211

8.​1 Two-Dimensional Diffusion in a Rectangular Domain 211

8.​2 Comments on the Discretized Equation 216

8.​2.​1 The Zero Sum Rule 216

8.​2.​2 The Opposite Signs Rule 217

8.​3 Boundary Conditions 217

8.​3.​1 Dirichlet Boundary Condition 218

8.​3.​2 Von Neumann Boundary Condition 220

8.​3.​3 Mixed Boundary Condition 222

8.​3.​4 Symmetry Boundary Condition 223

8.​4 The Interface Diffusivity 224

8.​5 Non-Cartesian Orthogonal Grids 239

8.​6 Non-orthogonal Unstructured Grid 241

8.​6.​1 Non-orthogonality 241

8.​6.​2 Minimum Correction Approach 242

8.​6.​3 Orthogonal Correction Approach 243

8.​6.​4 Over-Relaxed Approach 243

8.​6.​5 Treatment of the Cross-Diffusion Term 244

8.​6.​6 Gradient Computation 244

8.​6.​7 Algebraic Equation for Non-orthogonal Meshes 245

8.​6.​8 Boundary Conditions for Non-orthogonal Grids 252

8.​7 Skewness 254

8.​8 Anisotropic Diffusion 255

8.​9 Under-Relaxation of the Iterative Solution Process 256

8.​10 Computational Pointers 258

8.​10.​1 uFVM 258

8.10.2 OpenFOAM ® 260

8.​11 Closure 265

8.​12 Exercises 265

References 270

9 Gradient Computation 273

9.​1 Computing Gradients in Cartesian Grids 273

9.​2 Green-Gauss Gradient 275

9.​3 Least-Square Gradient 285

9.​4 Interpolating Gradients to Faces 289

9.​5 Computational Pointers 290

9.​5.​1 uFVM 290

9.5.2 OpenFOAM ® 295

9.​6 Closure 298

9.​7 Exercises 298

References 302

10 Solving the System of Algebraic Equations 303

10.​1 Introduction 303

10.​2 Direct or Gauss Elimination Method 305

10.​2.​1 Gauss Elimination 305

10.​2.​2 Forward Elimination 306

10.​2.​3 Forward Elimination Algorithm 307

10.​2.​4 Backward Substitution 307

10.​2.​5 Back Substitution Algorithm 308

10.​2.​6 LU Decomposition 308

10.​2.​7 The Decomposition Step 310

10.​2.​8 LU Decomposition Algorithm 311

10.​2.​9 The Substitution Step 312

10.​2.​10 LU Decomposition and Gauss Elimination 312

10.​2.​11 LU Decomposition Algorithm by Gauss Elimination 313

10.​2.​12 Direct Methods for Banded Sparse Matrices 315

10.​2.​13 TriDiagonal Matrix Algorithm (TDMA) 316

10.​2.​14 PentaDiagonal Matrix Algorithm (PDMA) 317

10.​3 Iterative Methods 319

10.​3.​1 Jacobi Method 323

10.​3.​2 Gauss-Seidel Method 325

10.​3.​3 Preconditioning and Iterative Methods 327

10.​3.​4 Matrix Decomposition Techniques 329

10.​3.​5 Incomplete LU (ILU) Decomposition 329

10.​3.​6 Incomplete LU Factorization with no Fill-in ILU(0) 330

10.​3.​7 ILU(0) Factorization Algorithm 331

10.​3.​8 ILU Factorization Preconditioners 331

10.3.9 Algorithm for the Calculation of $$ {{\bf D}}^{*} $$ in the DILU Method 332

10.​3.​10 Forward and Backward Solution Algorithm with the DILU Method 333

10.​3.​11 Gradient Methods for Solving Algebraic Systems 333

10.​3.​12 The Method of Steepest Descent 335

10.​3.​13 The Conjugate Gradient Method 337

10.​3.​14 The Bi-conjugate Gradient Method (BiCG) and Preconditioned BICG 340

10.​4 The Multigrid Approach 343

10.​4.​1 Element Agglomeration/​Coarsening 345

10.​4.​2 The Restriction Step and Coarse Level Coefficients 346

10.​4.​3 The Prolongation Step and Fine Grid Level Corrections 349

10.​4.​4 Traversal Strategies and Algebraic Multigrid Cycles 349

10.​5 Computational Pointers 350

10.​5.​1 uFVM 350

10.5.2 OpenFOAM ® 351

10.​6 Closure 358

10.​7 Exercises 358

References 362

11 Discretization of the Convection Term 365

11.​1 Introduction 365

11.​2 Steady One Dimensional Convection and Diffusion 366

11.​2.​1 Analytical Solution 366

11.​2.​2 Numerical Solution 368

11.​2.​3 A Preliminary Derivation:​ The Central Difference (CD) Scheme 369

11.​2.​4 The Upwind Scheme 375

11.​2.​5 The Downwind Scheme 379

11.​3 Truncation Error:​ Numerical Diffusion and Anti-Diffusion 380

11.​3.​1 The Upwind Scheme 381

11.​3.​2 The Downwind Scheme 382

11.​3.​3 The Central Difference (CD) Scheme 383

11.​4 Numerical Stability 385

11.​5 Higher Order Upwind Schemes 388

11.​5.​1 Second Order Upwind Scheme 389

11.​5.​2 The Interpolation Profile 390

11.​5.​3 The Discretized Equation 390

11.​5.​4 Truncation Error 391

11.​5.​5 Stability Analysis 392

11.​5.​6 The QUICK Scheme 392

11.​5.​7 The Interpolation Profile 393

11.​5.​8 Truncation Error 394

11.​5.​9 Stability Analysis 394

11.​5.​10 The FROMM Scheme 395

11.​5.​11 The Interpolation Profile 395

11.​5.​12 The Discretized Equation 396

11.​5.​13 Truncation Error 397

11.​5.​14 Stability Analysis 397

11.​5.​15 Comparison of the Various Schemes 398

11.​5.​16 Functional Relationships for Uniform and Non-uniform Grids 399

11.​6 Steady Two Dimensional Advection 400

11.​6.​1 Error Sources 404

11.​7 High Order Schemes on Unstructured Grids 406

11.​7.​1 Reformulating HO Schemes in Terms of Gradients 407

11.​8 The Deferred Correction Approach 409

11.​9 Computational Pointers 411

11.​9.​1 uFVM 411

11.9.2 OpenFOAM ® 413

11.​10 Closure 421

11.​11 Exercises 422

References 426

12 High Resolution Schemes 429

12.​1 The Normalized Variable Formulation (NVF) 429

12.​2 The Convection Boundedness Criterion (CBC) 436

12.​3 High Resolution (HR) Schemes 438

12.​4 The TVD Framework 443

12.​5 The NVF-TVD Relation 450

12.​6 HR Schemes in Unstructured Grid Systems 456

12.​7 Deferred Correction for HR Schemes 456

12.​7.​1 The Difficulty with the Direct Use of Nodal Values 458

12.​8 The DWF and NWF Methods 459

12.​8.​1 The Downwind Weighing Factor (DWF) Method 460

12.​8.​2 The Normalized Weighing Factor (NWF) Method 463

12.​9 Boundary Conditions 467

12.​9.​1 Inlet Boundary Condition 468

12.​9.​2 Outlet Boundary Condition 470

12.​9.​3 Wall Boundary Condition 471

12.​9.​4 Symmetry Boundary Condition 472

12.​10 Computational Pointers 472

12.​10.​1 uFVM 472

12.10.2 OpenFOAM ® 475

12.​11 Closure 483

12.​12 Exercises 483

References 487

13 Temporal Discretization:​ The Transient Term 489

13.​1 Introduction 489

13.​2 The Finite Difference Approach 492

13.​2.​1 Forward Euler Scheme 492

13.​2.​2 Stability of the Forward Euler Scheme 494

13.​2.​3 Backward Euler Scheme 498

13.​2.​4 Crank-Nicolson Scheme 500

13.​2.​5 Implementation Details 502

13.​2.​6 Adams-Moulton Scheme 503

13.​3 The Finite Volume Approach 507

13.​3.​1 First Order Transient Schemes 508

13.​3.​2 First Order Implicit Euler Scheme 508

13.​3.​3 First Order Explicit Euler Scheme 510

13.​3.​4 Second Order Transient Euler Schemes 512

13.​3.​5 Crank-Nicholson (Central Difference Profile) 512

13.​3.​6 Second Order Upwind Euler (SOUE) Scheme 514

13.​3.​7 Initial Condition for the FV Approach 515

13.​4 Non-Uniform Time Steps 519

13.​4.​1 Non-Uniform Time Steps with the Finite Difference Approach 519

13.​4.​2 Adams-Moulton (or SOUE) Scheme 521

13.​4.​3 Non-Uniform Time Steps with the Finite Volume Approach 522

13.​4.​4 Crank-Nicolson Scheme 523

13.​4.​5 Adams-Moulton (or SOUE) Scheme 524

13.​5 Computational Pointers 525

13.​5.​1 uFVM 525

13.5.2 OpenFOAM ® 526

13.​6 Closure 529

13.​7 Exercises 529

References 533

14 Discretization of the Source Term, Relaxation, and Other Details 535

14.​1 Source Term Discretization 535

14.​2 Under-Relaxation of the Algebraic Equations 538

14.​2.​1 Under-Relaxation Methods 539

14.​2.​2 Explicit Under-Relaxation 540

14.​2.​3 Implicit Under-Relaxation Methods 540

14.​3 Residual Form of the Equation 544

14.​3.​1 Residual Form of Patankar’s Under-Relaxation 545

14.​4 Residuals and Solution Convergence 546

14.​4.​1 Residuals 546

14.​4.​2 Absolute Residual 547

14.​4.​3 Maximum Residual 547

14.​4.​4 Root-Mean Square Residual 547

14.​4.​5 Normalization of the Residual 548

14.​5 Computational Pointers 549

14.​5.​1 uFVM 549

14.5.2 OpenFOAM ® 550

14.​6 Closure 555

14.​7 Exercises 555

References 557

Part III Algorithms

15 Fluid Flow Computation:​ Incompressible Flows 561

15.​1 The Main Difficulty 561

15.​2 A Preliminary Derivation 563

15.​2.​1 Discretization of the Momentum Equation 564

15.​2.​2 Discretization of the Continuity Equation 565

15.​2.​3 The Checkerboard Problem 565

15.​2.​4 The Staggered Grid 567

15.​2.​5 The Pressure Correction Equation 569

15.​2.​6 The SIMPLE Algorithm on Staggered Grid 572

15.​2.​7 Pressure Correction Equation in Two Dimensional Staggered Cartesian Grids 578

15.​2.​8 Pressure Correction Equation in Three Dimensional Staggered Cartesian Grid 581

15.​3 Disadvantages of the Staggered Grid 582

15.​4 The Rhie-Chow Interpolation 585

15.​5 General Derivation 588

15.​5.​1 The Discretized Momentum Equation 588

15.​5.​2 The Collocated Pressure Correction Equation 592

15.5.3 Calculation of the $$ {{\cal D}}_{f} $$ Term 596

15.​5.​4 The Collocated SIMPLE Algorithm 597

15.​6 Boundary Conditions 602

15.​6.​1 Boundary Conditions for the Momentum Equation 603

15.​6.​2 Boundary Conditions for the Pressure Correction Equation 617

15.​7 The SIMPLE Family of Algorithms 621

15.​7.​1 The SIMPLEC Algorithm 623

15.​7.​2 The PRIME Algorithm 624

15.​7.​3 The PISO Algorithm 625

15.8 Optimum Under-Relaxation Factor Values for v and $$ p^{\prime} $$ 628

15.​9 Treatment of Various Terms with the Rhie-Chow Interpolation 630

15.​9.​1 Treatment of the Under-Relaxation Term 630

15.​9.​2 Treatment of the Transient Term 631

15.​9.​3 Treatment of the Body Force Term 632

15.​9.​4 Combined Treatment of Under-Relaxation, Transient, and Body Force Terms 636

15.​10 Computational Pointers 636

15.​10.​1 uFVM 636

15.10.2 OpenFOAM ® 638

15.​11 Closure 649

15.​12 Exercises 649

References 653

16 Fluid Flow Computation:​ Compressible Flows 655

16.​1 Historical 655

16.​2 Introduction 656

16.​3 The Conservation Equations 657

16.​4 Discretization of the Momentum Equation 658

16.​5 The Pressure Correction Equation 659

16.​6 Discretization of The Energy Equation 663

16.​6.​1 Discretization of the Extra Terms 663

16.​6.​2 The Algebraic Form of the Energy Equation 665

16.​7 The Compressible SIMPLE Algorithm 666

16.​8 Boundary Conditions 667

16.​8.​1 Inlet Boundary Conditions 669

16.​8.​2 Outlet Boundary Conditions 672

16.​9 Computational Pointers 673

16.​9.​1 uFVM 673

16.9.2 OpenFOAM ® 674

16.​10 Closure 687

16.​11 Exercises 687

References 689

Part IV Applications

17 Turbulence Modeling 693

17.​1 Turbulence Modeling 693

17.​2 Reynolds Averaging 696

17.​2.​1 Time Averaging 696

17.​2.​2 Spatial Averaging 696

17.​2.​3 Ensemble Averaging 697

17.​2.​4 Averaging Rules 697

17.​2.​5 Incompressible RANS Equations 697

17.​3 Boussinesq Hypothesis 699

17.​4 Turbulence Models 700

17.​5 Two-Equation Turbulence Models 700

17.5.1 Standard k  − ɛ Model 700

17.5.2 The k  −  ω Model 702

17.5.3 The Baseline (BSL) k  −  ω Model 704

17.5.4 The Shear Stress Transport (SST) k  −  ω Model 705

17.​6 Summary of Incompressible Turbulent Flow Equations 707

17.​7 Discretization of the Turbulent Flow Equations 707

17.7.1 The Discretized Form of the k Equation 708

17.7.2 The Discretized Form of the ɛ Equation 708

17.7.3 The Discretized Form of the ω Equation 709

17.​8 Boundary Conditions 710

17.​8.​1 Modeling Flow Near the Wall 710

17.​8.​2 Standard Wall Functions 711

17.​8.​3 Improved Wall Functions 716

17.​8.​4 Scalable Wall Functions 718

17.​8.​5 Wall Boundary Conditions for Low Reynolds Number Models 719

17.​8.​6 Automatic Near-Wall Treatment 720

17.​8.​7 Near-Wall Heat Transfer 721

17.​8.​8 Other Boundary Conditions 722

17.​9 Calculating Normal Distance to the Wall 723

17.​10 Computational Pointers 725

17.10.1 The k  −  ɛ Model 727

17.10.2 The SST k  –  ω  Model 734

17.​10.​3 simpleFoamTurbul​ent 738

17.​11 Closure 740

17.​12 Exercises 740

References 742

18 Boundary Conditions in OpenFOAM ® and uFVM 745

18.1 Boundary Conditions in OpenFOAM ® 745

18.​2 Boundary Condition Customization 747

18.​3 Development of a New BC:​ No Slip Wall Condition 752

18.​4 The No-Slip Boundary Condition in uFVM 756

18.​5 Closure 759

Reference 759

19 An OpenFOAM ® Turbulent Flow Application 761

19.​1 Introduction 761

19.​2 The Ahmed Bluff Body 761

19.​3 Domain Discretization 763

19.​3.​1 Initial and Boundary Conditions 768

19.​3.​2 Systems Files 770

19.​3.​3 Running the Solver 773

19.​4 Conclusion 776

References 776

20 Closing Remarks 777

Erratum to:​ The Finite Volume Method in Computational Fluid Dynamics E1

Appendix: uFVM779

About the Authors

Fadl Moukalled

received his Ph.D. in Mechanical Engineering from Louisiana State University in 1987. During that same year, he joined the Mechanical Engineering Department at the American University of Beirut where currently he serves as a professor. His research interests cover several aspects of the finite volume method and its use in computational fluid dynamics. As a founding member of the CFD Group at AUB, he worked on convection schemes, pressure-based segregated algorithms for incompressible and compressible flows, adaptive grid methods, multigrid methods, transient schemes for free surface flows, multiphase flows, and fully coupled pressure-based solvers for incompressible, compressible, and multiphase flows.

Luca Mangani

received his Ph.D. form the University of Florence in 2006, where he worked on the development of a state-of-the-art turbo machinery code in OpenFOAM ® for heat transfer and combustion analysis. After three years of postdoc work, he joined the Lucerne University of Applied Sciences and Arts as senior research and chief engineer for CFD simulations. Since 2014, he is serving as an associate professor at the Fluid Mechanics and Hydro-machines Department, where he manages a variety of projects with industrial partners aimed at developing advanced and novel CFD tools. His research interests include pressure- and density-based solvers, segregated and fully coupled algorithms, fluid-structure interaction (FSI), turbulence, and conjugate heat transfer modeling.

Marwan Darwish

received his Ph.D. in Materials Processing from BRUNEL University in 1991. He worked at the BICOM institute for one year as a postdoc before joining the Mechanical Engineering Department at the American University of Beirut in 1992, where he currently serves as a professor. His research interest covers a range of topics including solidification, advanced numerics, free surface flow, high-resolution schemes, multiphase flows, coupled algorithms, and algebraic multigrid. He is a founding member of the CFD Group at AUB.

Part I
Foundation

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_1

1. Introduction

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter presents an overview of the book. It starts with a brief description of Computational Fluid Dynamics (CFD) and its use as a core design tool in a whole class of applications, and of the Finite Volume Method (FVM) and its role in the advancement of CFD. The chapter ends with a discussion of the book philosophy, structure, and content.

1.1 What Is Computational Fluid Dynamics (CFD)

“We are literally at a significant point in history. A third branch of the scientific method, computer simulation, is emerging as a day-to-day tool. It is taking its place next to experimental development and mathematical theory as a way to new discoveries in science and engineering”. This was part of the speech of John Rollwagen, chairman and CEO of Cray Research, to the opening session of Supercomputing 89.

While it is common to refer to this or similar statements about the importance of simulation tools and techniques to the advancement of science and technology in general, it is now very clear that the use of simulation tools has become crucial to the development of a wide range of everyday technologies. In fact, numerical simulation tools nowadays play the role of technology enablers.

Computational Fluid Dynamics (CFD) is one such tool. Even though the impetus to its development was initially provided by some sections within the aeronautics and aerospace industry, it has grown to become an essential tool in a range of other design intensive industries such as the automotive, power generation, chemical, nuclear, and marine industries, to cite a few. Over the past decade newer industries have joined the ranks of heavy CFD users: for example in the electronics industry CFD is employed to optimize energy systems and heat transfer for the cooling of electronic devices, in the biomedical industry CFD is now a core development and validation tool for medical applications, and in the building industry CFD is used in HVAC (heating, ventilating, and air conditioning), in fire simulation, and in air-quality assessment.

This has happened in little over two decades since the statement of John Rollwagen was made and over four decades since the development of the seminal SIMPLE algorithm by the CFD group of Brian Spalding at Imperial College in the early 70s.

Computational Fluid Dynamics is just one of the later Computer Aided Engineering tools that has gone mainstream. It has joined a well-established set of tools, such as the Finite Element Analysis (FEA) for Solid Mechanics and Vibration that has been part of the engineering design cycle since the mid 80s. The reason for this delay is the complexity of the equations that need to be solved. At their center is the Navier-Stokes equation that amazingly enough models accurately a whole set of flow phenomena from turbulent or laminar single phase incompressible flows, to compressible all-speed flows, and all the way to multiphase flows.

Amongst the numerical methods used to implement CFD, the Finite Volume Method has come to play a unique role.

1.2 What Is the Finite Volume Method

The Finite Volume Method (FVM) is a numerical technique that transforms the partial differential equations representing conservation laws over differential volumes into discrete algebraic equations over finite volumes (or elements or cells). In a similar fashion to the finite difference or finite element method, the first step in the solution process is the discretization of the geometric domain, which, in the FVM, is discretized into non-overlapping elements or finite volumes. The partial differential equations are then discretized/transformed into algebraic equations by integrating them over each discrete element. The system of algebraic equations is then solved to compute the values of the dependent variable for each of the elements.

In the finite volume method, some of the terms in the conservation equation are turned into face fluxes and evaluated at the finite volume faces. Because the flux entering a given volume is identical to that leaving the adjacent volume, the FVM is strictly conservative. This inherent conservation property of the FVM makes it the preferred method in CFD. Another important attribute of the FVM is that it can be formulated in the physical space on unstructured polygonal meshes. Finally in the FVM it is quite easy to implement a variety of boundary conditions in a non-invasive manner, since the unknown variables are evaluated at the centroids of the volume elements, not at their boundary faces.

These characteristics have made the Finite Volume Method quite suitable for the numerical simulation of a variety of applications involving fluid flow and heat and mass transfer, and developments in the method have been closely entwined with advances in CFD. From a limited potential at inception confined to solving simple physics and geometry over structured grids, the FVM is now capable of dealing with all kinds of complex physics and applications.

1.3 This Book

This book is about the Finite Volume Method and Computational Fluid Dynamics. It incorporates the basic know how of the method as acquired by the authors over almost three decades of work in the area. The terminology was carefully chosen, and vector notation was used whenever possible to ensure conciseness and consistency across all topics covered. Derivations are presented in a step by step fashion and illustrations are used extensively in the book to clarify concepts. In addition, a number of solved examples and exercises are also provided. Each chapter ends with a section denoted by “Computational Pointers” that provides pertinent details on implementation issues for two codes. The first, denoted by uFVM, is a Matlab®-based unstructured finite volume CFD educational code developed by the authors; while the second is OpenFOAM®, an open source finite volume code written in C++ capable of solving industrial type problems. Generally the numerics in each chapter are first presented for a one dimensional grid and progress towards two and three dimensional unstructured grids, to ease the introduction of difficult techniques.

The material presented allows the book to be utilized in a variety of ways. It can be used as a textbook for a senior undergraduate course covering the fundamentals of the finite volume discretization. It can also be deployed as a textbook for a graduate course on the application of the finite volume method and its use in computational fluid dynamics. It is also a handy reference book for workers in CFD, numerical heat transfer, and transport phenomena in general.

The content of the book falls into 20 chapters that may be grouped under the following four categories: (i) Foundation (Chaps. 2 through 7), (ii) Numerics (Chaps. 8 through 14), (iii) Algorithms (Chaps. 15 and 16), and (iv) Applications (17 through 19). Chapter 20 presents some closing remarks.

The uFVM Matlab® computer program, the OpenFOAM® developed routines, and the prepared lecture presentations can be downloaded from the book webpage at the following URL: “https://​feaweb.​aub.​edu.​lb/​research/​cfd”

A summary of the material covered in the forthcoming chapters is presented next.

1.3.1 Foundation

This part, covered in Chaps. 2 through 7, provides the necessary background for introducing the FVM.

Chapter 2 presents a short introduction of the elements of linear algebra including vectors, matrices, tensors, and their practices. This is in addition to an examination of the fundamental theorems of vector calculus.

Chapter 3 overviews the conservation principles governing fluid flow and related transport phenomena. It describes the derivations of the continuity, momentum, and energy equations (collectively known as the Navier-Stokes equations). This is followed by the development of a typical conservation equation for a general scalar, vector, or tensor quantity. This equation forms the cornerstone for the developments presented in the numerics section. The conservation equation is shown to be composed of a transient, convection, diffusion, and source term. The discretization of each of these terms is presented in a separate chapter.

Chapter 4 summarizes the various steps of the discretization process, which include: (i) modeling the geometric domain and the physical phenomena, (ii) the discretization of the modeled geometric domain into a grid system, (iii) the discretization of the partial differential equation into an equivalent system of algebraic equations defined over each of the elements of the computational domain, and (iv) the solution of the system of equations.

Chapter 5 transforms the partial differential equation into a set of semi-discretized equations and presents a broad review of the numerical issues pertaining to the finite volume method. This provides a solid foundation for the chapters that follow.

Chapter 6 is devoted to the finite volume mesh. It starts with mesh discretization that replaces the geometric domain by a set of non overlapping elements. Then it proceeds with the computation of geometric information relevant to the various entities of the computational mesh in addition to the topological information that describes the arrangement and inter-relations of these entities.

Chapter 7 outlines the design decisions that shape the implementation of the two CFD codes, uFVM and OpenFOAM®. First the data structure and memory management schemes of the two codes are presented, then a sample test case is presented. Finally the format of the system of equations generated by each of the two codes are detailed.

1.3.2 Numerics

The material relevant to this part is covered in Chaps. 8 through 14. Each chapter specializes in the discretization of one of the terms in the general conservation equation derived in Chap. 2, with the exception of Chap. 10, which deals with linear solvers of algebraic systems of equations.

Chapter 8 describes the discretization of the diffusion term. The developments start on a structured Cartesian mesh and progress to unstructured non-orthogonal grid, while explaining the adopted treatment of the non-orthogonal cross-diffusion term. The chapter continues with a discussion on the used interpolation profiles and the rules that should be satisfied by the coefficients of the discretized system of algebraic equations. It also details the implementation of boundary conditions in addition to the under-relaxation procedure needed for highly non-linear problems.

Chapter 9 describes several techniques for evaluating gradients on a general mesh topology following either the Green-Gauss or the least square approach. It also presents methods to interpolate the gradient to element faces.

Chapter 10 deals with solvers of systems of algebraic equations. Both direct and iterative solvers are discussed with emphasis on iterative solvers because direct solvers are rarely used in CFD applications. The direct methods presented include the Gauss elimination and LU factorization. The concept of preconditioning is presented and the performance and limitations of some iterative methods are reviewed. This include the Jacobi, Gauss-Siedel, Incomplete LU factorization, and the conjugate gradient methods. The chapter also introduces the algebraic multigrid method, which is generally used in combination with iterative solvers to accelerate their convergence.

Chapter 11 proceeds with the discretization of the convection term assuming a known flow field. The shortcomings of using a symmetrical linear profile for the discretization of the convection term are delineated and a remedy is suggested through the use of an upwind profile. The high diffusion error associated with the upwind scheme is pointed out and upwind-biased higher order schemes are suggested.

Chapter 12 continues the developments of convection schemes and discusses approaches by which the dispersion error (unboundedness of the interpolation profile) affecting High Order (HO) schemes is resolved. This is achieved by enforcing a Convection Boundedness Criterion (CBC) on the HO profiles resulting in the group of High Resolution (HR) schemes. The Normalized Variable Formulation (NVF) and the Total Variation Diminishing (TVD) frameworks for constructing these HR schemes are presented. The commonality between the two approaches is explained through the Normalized Variable Diagram (NVD) and Sweby’s diagram used in the NVF and TVD formulation, respectively. Many schemes are presented in the context of both formulations. Techniques for the implementation of HR schemes in structured and unstructured grids are reported.

Chapter 13 focusses on the discretization of the unsteady term that arises in the simulation of transient problems. Several transient schemes are developed following two different approaches. In the first, a finite difference approximation (via Taylor expansion) is used. In the second approach, the finite volume method is used on a temporal element in a similar fashion to what was done to the convection term.

Chapter 14 is devoted to a number of “small” numerical details that may have “big” effects on the convergence behavior. First the linearization of the source term when it is solution dependent is discussed. Then explicit and implicit techniques for under relaxing the algebraic equations are presented. The chapter ends with an examination of convergence indicators.

1.3.3 Algorithms

The previous chapters solved the general conservation equation assuming a given flow field. In general, the flow field is not known and has to be computed. This is the subject of Chaps. 15 and 16.

Chapter 15 is concerned with the prediction of incompressible flows. The difficulties associated with resolving the strong coupling between pressure and velocity, with the absence of an equation for pressure, are overcome by the SIMPLE algorithm with the derivation of a pressure correction equation. The Rhie-Chow interpolation is then introduced to allow realizing solutions to flow problems on collocated grids. Finally the implementation of a number of frequently encountered boundary conditions is detailed.

Chapter 16 extends the SIMPLE algorithm into compressible flows. The dependence of density on pressure and temperature is accounted for in the pressure correction equation through a density correction, giving rise to a convection-like term that transforms the mathematical nature of the equation from elliptic (for incompressible flows) to hyperbolic. Implementation details for a number of boundary conditions are also provided.

1.3.4 Applications

This part describes the implementation and application of the numerical techniques developed in the previous chapters.

Chapter 17 applies these numerical techniques to address some of the challenges faced when solving turbulent flow problems. It introduces several two-equation turbulence models and details the treatment of the near wall region.

Chapter 18 reviews the implementation of boundary conditions in OpenFOAM® and provides the needed information for adding new boundary conditions in the code. The no-slip wall boundary condition is described in some details.

Chapter 19 outlines the solution procedure of a reference test case in which solvers and boundary conditions are applied to solve a turbulent incompressible flow problem.

Finally, Chapter 20 presents some closing remarks.

1.4 Closure

The chapter discussed the growing role played by Computational Fluid Dynamics (CFD) as a core design tool in a whole class of applications and provided a general overview of the Finite Volume Method (FVM). It also clarified the purpose of the book, its intended use, and a summary of its content. The next chapter will give a brief review of the mathematical operations that will be used throughout the book.

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_2

2. Review of Vector Calculus

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter sets the ground for the derivation of the conservation equations by providing a brief review of the continuum mechanics tools needed for that purpose while establishing some of the mathematical notations and procedures that will be used throughout the book. The review is by no mean comprehensive and assumes a basic knowledge of the fundamentals of continuum mechanics. A short introduction of the elements of linear algebra including vectors, matrices, tensors, and their practices is given. The chapter ends with an examination of the fundamental theorems of vector calculus, which constitute the elementary building blocks needed for manipulating and solving these conservation equations either analytically or numerically using computational fluid dynamics.

2.1 Introduction

The transfer phenomena of interest here can be mathematically represented by equations involving physical variables that fall under three categories: scalars, vectors, and tensors [1–3]. Throughout this book scalars are designated by lightface italic, vectors by lower boldface Roman, and tensors by boldface Greek letters. In addition, matrices are identified by upper boldface Roman letters.

A scalar represents a quantity that has magnitude such as volume $$ V $$, pressure $$ p $$, temperature $$ T $$, time $$ t $$, mass $$ m $$, and density $$ \rho $$. A vector represents a quantity of a given magnitude and direction such as velocity $$ {\mathbf{v}} $$, momentum $$ {\mathbf{L}} = m{\mathbf{v}} $$, and force $$ {\mathbf{F}} $$. A matrix is a rectangular array of quantities ordered along rows and columns. A tensor is a mathematical object analogous to but more general than a vector, represented by an array of components, such as the shear stress tensor. Moreover, the conservation equations are composed of terms that represent the product of two or more variables. The multiplication involved may be of various types to be detailed later and the variables could be a combination of the three types described above. Whenever the multiplication results in a scalar, the product will be enclosed by parentheses “(product)”, if it results in a vector it will be enclosed by square brackets “[product]”, and if it results in a tensor it will be enclosed by curly brackets “{product}”.

2.2 Vectors and Vector Operations

The most frequently used vector in fluid dynamics is the velocity vector that will be designated by $$ {\mathbf{v}} $$. The components of the velocity vector in a three-dimensional Cartesian coordinate system will be denoted by $$ u, v, $$ and $$ w $$ in the $$ x, y, $$ and $$ z $$ direction, respectively (Fig. 2.1). In Cartesian coordinates, $$ {\mathbf{v}} $$ is written as

(2.1)

where $$ {\mathbf{i}}, {\mathbf{j}}, $$ and $$ {\mathbf{k}} $$ are unit vectors in the $$ x, \,y, $$ and $$ z $$ direction, respectively. A vector is usually presented in a column format with its transpose, denoted with a superscript $$ {\text{T}} $$, in a row format as

(2.2)

The magnitude of a vector is given by

(2.3)

The sum of two vectors $$ {\mathbf{v}}_{1} $$ and $$ {\mathbf{v}}_{2} $$ is the sum of their components, i.e.,

(2.4)

or

(2.5)

The multiplication of a vector $$ {\mathbf{v}} $$ by a scalar $$ s $$ results in the vector $$ s{\mathbf{v}} $$ such that

(2.6)

The product of two vectors is not as straightforward. When multiplying a vector $$ {\mathbf{v}}_{1} $$ by another vector $$ {\mathbf{v}}_{2} $$ two types of multiplications arise [4–6]. The first is denoted by the scalar or dot product, $$ \left( {{\mathbf{v}}_{1} \cdot {\mathbf{v}}_{2} } \right) $$, and the second by vector or cross product $$ \left[ {{\mathbf{v}}_{1} \times {\mathbf{v}}_{2} } \right] $$.

Fig. 2.1

The components of a vector $$ \mathbf{v} $$ in a three-dimensional Cartesian coordinate system

2.2.1 The Dot Product of Two Vectors

By definition, the dot product of two vectors $$ {\mathbf{v}}_{1} $$ and $$ {\mathbf{v}}_{2} $$ is a scalar quantity given by

(2.7)

where $$ \cos \left( {{\mathbf{v}}_{1} ,{\mathbf{v}}_{2} } \right) $$ denotes the cosine of the angle between $$ {\mathbf{v}}_{1} $$ and $$ {\mathbf{v}}_{2} $$. From the definition of the vector dot product, it follows that

(2.8)

In terms of orthonormal Cartesian components, the dot product of the two vectors $$ {\mathbf{v}}_{1} $$ and $$ {\mathbf{v}}_{2} $$ can be calculated as

(2.9)

2.2.2 Vector Magnitude

From Eq. (2.9) it follows that the magnitude of a vector $$ {\mathbf{v}} $$ can be obtained as

(2.10)

2.2.3 The Unit Direction Vector

A unit vector $$ {\mathbf{e}}_{\text{v}} $$ in the direction of $$ {\mathbf{v}} $$ can be derived from the definition of the dot product as

(2.11)

Therefore the component of a vector in the direction of another vector (i.e., magnitude of the projected length) can be viewed as the dot product of the vector to be projected with the unit direction of the other vector as shown in Fig. 2.2a, b.

Fig. 2.2

a Projection of vector $$ {\mathbf{v}}_{1} $$ onto the unit direction of vector $$ {\mathbf{v}}_{2} $$; b Projection of vector $$ {\mathbf{v}}_{2} $$ onto the unit direction of vector $$ {\mathbf{v}}_{1} $$

2.2.4 The Cross Product of Two Vectors

Whereas the dot product of two vectors $$ {\mathbf{v}}_{1} $$ and $$ {\mathbf{v}}_{2} $$ is a scalar quantity, their cross or vector product is a vector $$ {\mathbf{v}}_{3} $$ normal to the plane formed by the vectors $$ {\mathbf{v}}_{1} $$ and $$ {\mathbf{v}}_{2} $$, of magnitude calculated as

(2.12)

and of direction given by the right hand rule. As shown in Fig. 2.3, the magnitude of the cross product of two vectors represents the area of the parallelogram spanned by the two vectors. Since, in addition, the resulting vector is normal to the plane formed by the vectors, the cross product of two vectors represents their surface vector.

Fig. 2.3

The cross product of two vectors

It is then clear that the cross product of two collinear vectors is zero as they define no area, and that the cross product of two orthogonal unit vectors is a unit vector perpendicular to the two unit vectors. Adopting the right hand rule to define the direction of the resulting vector, the following cross product operations hold:

(2.13)

Using the above relations, the cross product of two vectors in terms of their Cartesian components is given by

(2.14)

which can be written using determinant notation as

(2.15)

Example 1

Compute the area of the triangle formed by points (Fig. 2.4):$$ P_{1} \left( {0,\,0,\,0} \right),P_{2} \left( {1,\,0,\,0} \right) $$ and $$ P_{3} \left( {0.5,\,1,\,0} \right). $$

Fig. 2.4

Example 1

Solution

The surface defined by the triangle $$ \left( {P_{1} ,P_{2} ,P_{3} } \right) $$ can be computed using the cross product of two sides as

2.2.5 The Scalar Triple Product

In addition, combined products of three vectors $$ {\mathbf{v}}_{1} $$, $$ {\mathbf{v}}_{2} $$, and $$ {\mathbf{v}}_{3} $$ may arise such as $$ \left( {{\mathbf{v}}_{1} \cdot \left[ {{\mathbf{v}}_{2} \times {\mathbf{v}}_{3} } \right]} \right) $$, which can be calculated using the following determinant (to be explained later):

(2.16)

As shown in Fig. 2.5, the absolute value of the scalar triple product represents the volume of the parallelepiped formed by the vectors $$ {\mathbf{v}}_{1} $$, $$ {\mathbf{v}}_{2} $$, and $$ {\mathbf{v}}_{3} $$.

Fig. 2.5

Geometric representation of scalar triple product

Example 2

Compute the volume of the pyramid defined by the points: $$ P_{1} \left( {0,\,0,\,0} \right),P_{2} \left( {1,\,0,\,0} \right),P_{3} \left( {0.5,\,1,\,0} \right) $$, and $$ P_{4} \left( {0.5,\,0.5,\,1} \right) $$ shown in Fig. 2.6.

Fig. 2.6

Example 2

Solution

The volume of the pyramid can be computed using the scalar triple product as

2.2.6 Gradient of a Scalar and Directional Derivatives

An important vector operator, which arises frequently in fluid dynamics, is the “del” (or “nabla”) operator defined as

(2.17)

When the “del” operator is applied on a scalar variable $$ s $$ it results in the gradient of $$ s $$ [7, 8] given by

(2.18)

Thus the gradient of a scalar field is a vector field indicating that the value of $$ s $$ changes with position in both magnitude and direction.

The projection of $$ \nabla s $$ in a certain direction of unit vector $$ {\mathbf{e}}_{l} $$ is given by

(2.19)

and is called the directional derivative of $$ s $$ along the direction of the unit vector $$ {\mathbf{e}}_{l} $$, as schematically depicted in Fig. 2.7. The maximum value of the directional derivative is $$ \left\| {\nabla s} \right\| $$ and is obtained when $$ {\text{cos}}\left( {\nabla s,{\mathbf{e}}_{l} } \right) = 1 $$, that is in the direction of $$ \nabla s $$. Therefore, it can be stated that the gradient of a scalar field $$ s $$ indicates the direction and magnitude of the largest change in $$ s $$ at every point in space. Moreover, $$ \nabla s $$ is normal to the constant $$ s $$ surface that passes through that point.

Fig. 2.7

The rate of change of $$ s\left( {x,\,y,\,z} \right) $$ in the direction of vector $$ {\mathbf{e}}_{l} $$

Example 3

Let $$ f\left( {x,\,y,\,z} \right) = x^{2} y + y^{2} z + z^{2} x $$

(a)

find $$ \nabla f $$ at point $$ \left( {3,2,0} \right) $$.

(b)

find the derivative at point $$ \left( {3,2,0} \right) $$ along the direction $$ \left( {1,2,2} \right). $$

Solution

(a)

Thus

(b)

The unit vector along direction $$ \left( {1,2,2} \right) $$ is

The derivative along the direction $$ \left( {1,2,2} \right) $$ is

2.2.7 Operations on the Nabla Operator

The dot product of the del operator with a vector $$ {\mathbf{v}} $$ of components $$ u,\,v, $$ and $$ w $$ in the $$ x,\,y, $$ and $$ z $$ direction, respectively, results in the divergence of the vector [7, 8], which is a scalar quantity written as

(2.20)

Physically the divergence of a vector field over a region is a measure of how much the vector field points into or out of the region.

The divergence of the gradient of a scalar variable $$ s $$ is denoted by the Laplacian of $$ s $$ and is a scalar given by

(2.21)

The Laplacian of a vector follows from the above definition of the Laplacian operator and is a vector computed as

(2.22)

Example 4

Find the divergence of $$ {\mathbf{v}} = \left( {u,\,v,\,w} \right) = \left( {3x,\,2xy,\,4z} \right) $$

Solution

Then divergence of $$ {\mathbf{v}} $$ is obtained as

Another quantity of interest is the curl of a vector field [7, 8] formed between the “del” operator and the vector $$ {\mathbf{v}} $$, resulting in the following vector:

(2.23)

Examples of the divergence and curl of a vector field are schematically displayed in Fig. 2.8. The radial vector field shown in Fig. 2.8a has only divergence with zero curl. In fluid mechanics this vector field represents the velocity field of a sink/source flow. On the other hand Fig. 2.8b depicts a rotational vector field which has only curl with zero divergence (i.e., a divergence free vector field). Such a field corresponds to the velocity field of a vortex flow.

Fig. 2.8

a A radial vector field, b a solenoidal vector field

The divergence of a vector $$ {\mathbf{v}} $$ with its gradient also arises in the equations of interest in this book and is computed as

(2.24)

Example 5

Determine for the flow fields shown in Fig. 2.9a, b, c which is divergence free (i.e., neither expanding nor compressing) and which is irrotational (i.e., does not undergo a rotation)

Fig. 2.9

Example 5 a $$ \nabla \cdot {\mathbf{F}} = 0\quad \nabla \times {\mathbf{F}} = 0{\mathbf{i}} + 0{\mathbf{j}} + 2{\mathbf{k}} $$ b $$ \nabla \cdot {\mathbf{F}} = 0\quad \nabla \times {\mathbf{F}} = 0{\mathbf{i}} + 0{\mathbf{j}} + 0{\mathbf{k}} $$ c $$ \nabla \cdot {\mathbf{F}} = 2 + 2 = 4\quad \nabla \times {\mathbf{F}} = 0{\mathbf{i}} + 0{\mathbf{j}} + 0{\mathbf{k}} $$

2.2.8 Additional Vector Operations

If $$ s $$ is a scalar function, and $$ {\mathbf{v}}_{1} ,\,{\mathbf{v}}_{2} $$ and $$ {\mathbf{v}}_{3} $$ are vector fields, then the following relations, which are listed without proof, apply:

(2.25)

(2.26)

(2.27)

(2.28)

(2.29)

(2.30)

(2.31)

(2.32)

(2.33)

2.3 Matrices and Matrix Operations

A matrix $$ {\mathbf{A}} $$ of order $$ M \times N $$ is a rectangular array of quantities (numbers or expressions) arranged in $$ M $$ rows and $$ N $$ columns [9–11]. An element of $$ {\mathbf{A}} $$ located on the $$ i{\text{th}} $$ row and $$ j{\text{th}} $$ column is denoted by $$ a_{ij} $$. For example, element $$ a_{32} $$ of the $$ 4 \times 3 $$ matrix shown in Fig. 2.10 is 12.

Fig. 2.10

Example of a $$ 4 \times 3 $$ matrix

Based on this definition it follows that a column vector $$ {\mathbf{v}} $$ of dimensionality $$ N $$ is a matrix of order $$ N \times 1 $$ and a scalar $$ s $$ is a matrix of order $$ 1 \times 1 $$.

The transpose of a matrix $$ {\mathbf{A}} $$ of order $$ M \times N $$ is another matrix denoted by $$ {\mathbf{A}}^{\text{T}} $$ of order $$ N \times M $$ for which the rows of $$ {\mathbf{A}} $$ are the columns of $$ {\mathbf{A}}^{\text{T}} $$ and the columns of $$ {\mathbf{A}} $$ are the rows of $$ {\mathbf{A}}^{\text{T}} $$. Mathematically, this can be written as

(2.34)

Two matrices of the same order are equal if their corresponding elements are equal. Two matrices of the same order can be added or subtracted element by element. For example, if $$ {\mathbf{A}} $$ and $$ {\mathbf{B}} $$ are given by

then $$ {\mathbf{A}} + {\mathbf{B}} $$ and $$ {\mathbf{A}} - {\mathbf{B}} $$ are found to be

If a matrix is multiplied by a scalar $$ s $$ than all its elements are multiplied by $$ s $$. Mathematically this is written as

(2.35)

To multiply two matrices $$ {\mathbf{A}} $$ and $$ {\mathbf{B}} $$, the number of columns of $$ {\mathbf{A}} $$ must be equal to the number of rows of $$ {\mathbf{B}} $$. Therefore, if $$ {\mathbf{A}} $$ is of size $$ M \times X $$ for the product $$ {\mathbf{P}} = {\mathbf{AB}} $$ to be possible, $$ {\mathbf{B}} $$ must be of size $$ X \times N $$. The size of $$ {\mathbf{P}} $$ will be $$ M \times N $$ with its element $$ p_{ij} $$ obtained as

(2.36)

If $$ {\mathbf{A}} $$ is a $$ 3 \times 2 $$ matrix and $$ {\mathbf{B}} $$ a $$ 2 \times 4 $$ matrix given by

then $$ {\mathbf{P}} = {\mathbf{AB}} $$ will be a $$ 3 \times 4 $$ matrix computed as

2.3.1 Square Matrices

If the number of columns $$ N $$ of matrix $$ {\mathbf{A}} $$ is equal to its number of rows, then $$ {\mathbf{A}} $$ is a square matrix of order $$ N $$. The elements $$ a_{ii} $$ of a square matrix $$ {\mathbf{A}} $$ form its main diagonal which stretches from top left to bottom right. The diagonal composed of elements $$ a_{ij} $$ for which $$ i + j = N + 1 $$ is called the cross diagonal and it extends from the bottom left to top right.

Square matrices possess properties that are not applicable to other types of matrices such as symmetry and antisymmetry. In addition, many operations such as taking determinants and calculating eigenvalues are only defined for square matrices.

The result of multiplying a square matrix of order $$ N $$ by itself is a square matrix of order $$ N $$. Therefore a square matrix can be multiplied by itself as many times as needed and the notation $$ {\mathbf{A}}^{k} $$ designates $$ {\mathbf{A}} $$ multiplied by itself $$ k $$ times, i.e.,

(2.37)

A square matrix $$ {\mathbf{A}} $$ is symmetric if $$ a_{ij} = a_{ji} \left( {{\text{i.e.,}}\,{\mathbf{A}}^{\text{T}} = {\mathbf{A}}} \right) $$, and antisymmetric if $$ a_{ij} = - a_{ji} $$. An example of a symmetric square matrix of order 3 is

and of an antisymmetric square matrix of order 4 is

A diagonal square matrix $$ {\mathbf{D}} $$ is one for which all elements off the main diagonal are zero while elements on the main diagonal are arbitrary. An example of a square diagonal matrix of order 3 is

A diagonal matrix of order $$ N $$ for which all elements on the main diagonal are $$ 1 $$ (i.e., $$ a_{ii} = 1 $$) is called an identity matrix of order $$ N $$ and is designated by $$ {\mathbf{I}} $$. An identity matrix of order 4 is given by

The inverse of a square matrix $$ {\mathbf{A}} $$ of order $$ N $$ is the square matrix $$ {\mathbf{A}}^{ - 1} $$ of order $$ N $$ satisfying

(2.38)

An upper triangular matrix $$ {\mathbf{U}} $$ is a square matrix in which all elements below the main diagonal are zero. Mathematically this can be expressed as

(2.39)

A lower triangular matrix $$ {\mathbf{L}} $$ is a square matrix in which all elements above the main diagonal are zero. Using mathematical notation, this is written as

(2.40)

Examples of upper and lower triangular square matrices of order 3 are

2.3.2 Using Matrices to Describe Systems of Equations

Matrices can be used to compactly describe systems of equations [12]. A system of $$ N $$ equations in $$ N $$ unknowns can be written as

(2.41)

In matrix notation, this system of equations is equivalent to

(2.42)

or in compact form as

(2.43)

2.3.3 The Determinant of a Square Matrix

A determinant is a value associated with a square matrix $$ {\mathbf{A}} $$ that can be computed from the elements of the matrix through a mathematical procedure and is denoted by $$ { \det }\left( {\mathbf{A}} \right) $$ or $$ \left| {\mathbf{A}} \right| $$ (which should not be confused with the absolute value notation) [13]. The calculation of the determinant of a matrix of order 2 is straightforward and is the product of the elements in the main diagonal minus the product of the elements in the cross diagonal. If $$ {\mathbf{A}} $$ is a square matrix of order 2 then,

(2.44)

For higher order matrices the procedure is more involved and is based on the notion of minors and cofactors.

A minor $$ \left( {mi} \right)_{ij} $$ for an element $$ a_{ij} $$ is the determinant that results when the $$ i{\text{th}} $$ row and $$ j{\text{th}} $$ column are deleted. The cofactor $$ \left( {co} \right)_{ij} $$ of an element $$ a_{ij} $$ is the value of the minor multiplied by either a positive or a negative sign depending on whether $$ \left( {i + j} \right) $$ is even or odd, respectively. The mathematical relation between cofactors and minors can be written as

(2.45)

The determinant of a square matrix $$ {\mathbf{A}} $$ of order $$ N $$ is computed by finding the cofactors of one of its rows or its columns, multiplying each cofactor by the corresponding element, and adding the results. Mathematically this is given by

(2.46)

It should be clarified that the calculation of the cofactors may require further decomposition of the minor determinants. This decomposition may give rise to further decompositions until a determinant with a size of 2 is reached. Moreover, based on the above discussion it is easily demonstrated that the determinant of an upper, a lower, or a diagonal matrix $$ {\mathbf{A}} $$ of order $$ N $$ is the product of the elements along its main diagonal, i.e., $$ { \det }\left( {\mathbf{A}} \right) = \prod\limits_{i = 1}^{N} {a_{ii} } $$.

Example 6

Calculate the determinant of matrix $$ {\mathbf{A}} $$ of order 4 given by

Solution

As mentioned above, the determinant can be calculated based on the cofactors of any selected row or column. A smart choice would be a row or a column with the largest number of zeros. Therefore computations will be reduced by selecting either the first row or the last column. The determinant will be calculated using both to further show that the end results will be the same.

The signs of cofactors are

The determinant using cofactors of row 1 is computed as

The first new determinant is calculated using the cofactors of row 1 while the second determinant is calculated using cofactors of column 3 as

The determinant using cofactors of column 4 is calculated as

The first and second new determinants are calculated using the cofactors of row 1 as

As expected, the same value is obtained.

2.3.4 Eigenvectors and Eigenvalues

Consider a square matrix $$ {\mathbf{A}} $$ and a vector $$ {\mathbf{v}} $$. The vector $$ {\mathbf{v}} $$ is an eigenvector of $$ {\mathbf{A}} $$ if the product $$ {\mathbf{Av}} $$ results in a vector that has the same direction as $$ {\mathbf{v}} $$ [14–19]. Therefore an eigenvector of a matrix is a nonzero vector that does not rotate when is applied to it. As shown in Fig. 2.11, the only effects may be to change its length and/or reverse its direction. Thus, there exist a scalar $$ \lambda $$ such that $$ {\mathbf{Av}} = \lambda {\mathbf{v}} $$. The value of $$ \lambda $$ is an eigenvalue of $$ {\mathbf{A}} $$. It is clear that for any constant $$ \alpha $$ the vector $$ \alpha {\mathbf{v}} $$ is also an eigenvector of $$ {\mathbf{A}} $$ because $$ {\mathbf{A}}\left( {\alpha {\mathbf{v}}} \right) = \alpha {\mathbf{Av}} = \alpha \lambda {\mathbf{v}} = \lambda \left( {\alpha {\mathbf{v}}} \right) $$. Thus, a scaled eigenvector is also an eigenvector.

Fig. 2.11

Effects of multiplying a matrix $$ {\mathbf{A}} $$ by one of its Eigenvectors $$ {\mathbf{v}} $$

If $$ {\mathbf{A}} $$ is symmetric of order $$ N $$, then it can be shown that $$ {\mathbf{A}} $$ has a set of linearly independent eigenvectors denoted $$ {\mathbf{v}}_{1} ,\,{\mathbf{v}}_{2} ,\,{\mathbf{v}}_{3} ,\, \ldots ,\,{\mathbf{v}}_{N} $$. As proved above this set is not unique. However the corresponding set of their eigenvalues, denoted $$ \lambda_{1} ,\lambda_{2} ,\lambda_{3} ,\, \ldots ,\lambda_{N} $$, which may or may not be equal to each other, is unique. The eigenvalues of the identity matrix are all ones, and every nonzero vector is an eigenvector of $$ {\mathbf{I}} $$.

In general the eigenvalues of a square matrix $$ {\mathbf{A}} $$ of order $$ N $$ are obtained from solving the following equation:

(2.47)

Since, by definition, eigenvectors are nonzero, then

(2.48)

The expanded form of Eq. (2.48) is given by

(2.49)

As an example, the eigenvalues of the following square matrix of order 2 are found as:

2.3.5 A Symmetric Positive-Definite Matrix

A symmetric matrix $$ {\mathbf{A}} = \left[ {a_{ij} } \right] $$ of order $$ N $$ is positive-definite if for all column vectors $$ {\mathbf{p}} $$ in $$ {\text{R}}^{N} $$ the following inequality holds:

(2.50)

For example, if $$ {\mathbf{A}} $$ is an order 3 symmetric matrix given by

then Eq. (2.50) for any column vector $$ {\mathbf{p}} $$ of order 3 gives

which is positive-definite.

If $$ {\mathbf{A}} $$ is a symmetric positive-definite matrix given by

(2.51)

then, among others, the following properties apply:

1.

Any sub-matrix $$ {\mathbf{P}} $$ of $$ {\mathbf{A}} $$ of order $$ M\left( {1 \le M \le N} \right) $$ of the form

(2.52)

is also positive-definite.

2.

The $$ N $$ eigenvalues of $$ {\mathbf{A}} $$, λ₁, λ₂, λ₃,..., λN are positive.

3.

If all the eigenvalues of a matrix $$ {\mathbf{A}} $$ are positive, then $$ {\mathbf{A}} $$ is positive-definite.

4.

$$ {\mathbf{A}} $$ has a unique decomposition of the form $$ {\mathbf{A}} = {\mathbf{LL}}^{\text{T}} $$, where $$ {\mathbf{L}} $$ is a lower triangular matrix. This decomposition is known as the Cholesky decomposition.

2.3.6 Additional Matrix Operations

If $$ s_{1} $$ and $$ s_{2} $$ are scalar functions, $$ {\mathbf{I}} $$ an identity matrix, and $$ {\mathbf{A}},\,{\mathbf{B}} $$, and $$ {\mathbf{C}} $$ are matrices, then the various matrix operations, addition, subtraction, scalar multiplication, and matrix multiplication, have the following properties listed without proof:

(2.53)

(2.54)

(2.55)

(2.56)

(2.57)

(2.58)

(2.59)

(2.60)

(2.61)

(2.62)

(2.63)

(2.64)

2.4 Tensors and Tensor Operations

Tensors can be thought of as extensions to the ideas already used when defining quantities like scalars and vectors [2, 20, 21]. A scalar is a tensor of rank zero, and a vector is a tensor of rank one. Tensors of higher rank (2, 3, etc.) can be developed and their main use is to manipulate and transform sets of equations. Since within the scope of this book only tensors of rank two are needed, they will be referred to simply as tensors.

Similar to the flow velocity vector $$ {\mathbf{v}} $$, the deviatoric stress tensor $$ {\varvec{\tau}} $$ (Fig. 2.12) will be referred to frequently in this book and is used here to illustrate tensor operations.

Fig. 2.12

Schematic of a stress tensor field

Let $$ x,y, $$ and $$ z $$ represent the directions in an orthonormal Cartesian coordinate system, then the stress tensor $$ {\varvec{\tau}} $$ and its transpose designated with superscript $$ {\text{T}}\left( {{\varvec{\tau}}^{\text{T}} } \right) $$ are represented in terms of their components as

(2.65)

Similar to writing a vector in terms of its components, defining the unit vectors i, j, and k in the $$ x,y, $$ and $$ z $$ direction, respectively, the tensor $$ {\varvec{\tau}} $$ given by Eq. (2.65) can be written in terms of its components as

(2.66)

Equation (2.66) allows defining a third type of vector product for multiplying two vectors, known as the dyadic product, and resulting in a tensor with its components formed by ordered pairs of the two vectors. In specific, the dyadic product of a vector $$ {\mathbf{v}} $$ by itself, arising in the formulation of the momentum equation of fluid flow, gives

(2.67)

The gradient of a vector $$ {\mathbf{v}} $$ is a tensor given by

(2.68)

The sum of two tensors $$ {\varvec{\sigma}} $$ and $$ {\varvec{\tau}} $$ is a tensor $$ \mathbf{\Sigma} $$ whose components are the sum of the corresponding components of the two tensors, i.e.,

(2.69)

Multiplying a tensor $$ {\varvec{\tau}} $$ by a scalar $$ s $$ results in a tensor whose components are multiplied by that scalar, i.e.,

(2.70)

The dot product of a tensor $$ {\varvec{\tau}} $$ by a vector $$ {\mathbf{v}} $$ results in the following vector:

(2.71)

which upon expanding becomes

(2.72)

Using Eq. (2.8), Eq. (2.72) reduces to

(2.73)

The above equation can be derived using matrix multiplication as

(2.74)

In a similar way the divergence of a tensor $$ {\varvec{\tau}} $$ is found to be a vector given by

(2.75)

The double dot product of two tensors $$ {\varvec{\tau}} $$ and $$ \left\{ {\nabla {\mathbf{v}}} \right\} $$ is a scalar computed as

(2.76)

The final value is obtained by expanding the above product and performing the double dot product on the various terms. For example,

(2.77)

Performing the same steps on every term in the expanded product, the final form of $$ ({\varvec{\tau}}:\nabla {\mathbf{v}}) $$ is obtained as

(2.78)

2.5 Fundamental Theorems of Vector Calculus

All mathematical formulations presented in this book will be performed using vectors. Therefore a good knowledge of the fundamental theorems of vector calculus is helpful. A brief review of some of these theorems is presented next.

2.5.1 Gradient Theorem for Line Integrals

The gradient theorem for line integrals relates a line integral to the values of a function at its endpoints [22]. It states that if $$ C $$ is a smooth curve, as shown in Fig. 2.13, described by the vector $$ {\mathbf{r}}\left( t \right) = {\mathbf{r}}\left[ {x\left( t \right),y\left( t \right),z\left( t \right)} \right] $$ for $$ a \le t \le b $$, and $$ s $$ is a scalar function whose gradient, $$ \nabla s $$, is continuous on $$ C $$, then

(2.79)

where $$ a $$ and $$ b $$ are the endpoints of $$ C $$. It follows that the value of the integral over a closed contour is zero.

Fig. 2.13

A schematic depiction of a curve $$ C $$ of a scalar function s showing its end points and the position vector $$ {\mathbf{r}}\left( t \right) $$

2.5.2 Green’s Theorem

Green’s theorem expresses the contour integral of a simple closed curve $$ C $$ in terms of the double integral of the two dimensional region $$ R $$ bounded by $$ C $$ [23–26].

Let $$ C $$ denotes the closed contour (Fig. 2.14) of a two dimensional region $$ R $$. If $$ u\left( {x,y} \right) $$ and $$ v\left( {x,y} \right) $$ are functions of continuous partial derivatives defined on $$ R $$, then

(2.80)

Fig. 2.14

Schematic of a region $$ R $$ and its closed contour $$ C $$

In Eq. (2.80) the contour integral along $$ C $$ is taken positive in the counterclockwise direction.

Green’s theorem can be written in a more compact form using vectors. For that purpose defining $$ d{\mathbf{r}},\,{\mathbf{v}} $$ and the area vector $$ d{\mathbf{S}} $$ as

(2.81)

then the vector form of Green’s theorem is given by

(2.82)

Green’s theorem is helpful for computing line integrals arising in two-dimensional flows.

Example 7

Compute $$ \oint\limits_{C} {2y^{3} \,dx + 3xy^{2} \,dy} $$ where$$ C $$ is the CCW-oriented boundary of the region $$ R $$ shown in Fig. 2.15.

The vector field in the above integral is $$ \left( {u,\,v} \right) = \left( {2y^{3} ,\,3xy^{2} } \right) $$. The line integral can be computed directly. But, it is more easily computed using Green’s theorem using a double integral. Applying Green’s theorem the integrand is obtained as

Since the line integral is over a semi circle, the region $$ R $$ is mathematically given by

The value of the integral is obtained as

Let $$ x = \cos \theta \Rightarrow dx = - \sin \theta d\theta $$

Thus

Fig. 2.15

Example 7

2.5.3 Stokes’ Theorem

Stokes’ theorem is a higher dimensional version of Green’s theorem [27–29]. Whereas Green’s theorem relates a line integral to a double integral, Stokes theorem relates a line integral to a surface integral. Let $$ {\mathbf{v}} $$ be a vector field, $$ S $$ an oriented surface, and $$ C $$ the boundary curve of $$ S $$, oriented using the right-hand rule, as depicted in Fig. 2.16. Stokes’ theorem states the following:

(2.83)

where $$ {\mathbf{r}} $$ is such that $$ {{d{\mathbf{r}}} \mathord{\left/ {\vphantom {{d{\mathbf{r}}} {d{\text{s}}}}} \right. \kern-0pt} {d{\text{s}}}} $$ is the unit tangent vector and $$ s $$ the arc length of $$ C $$. The curve of the line integral, $$ C $$, must have positive orientation, meaning that $$ d{\mathbf{r}} $$ points counterclockwise when the surface normal, $$ d{\mathbf{S}} $$, points toward the viewer, following the right-hand rule.

Fig. 2.16

A surface $$ S $$ in a three-dimensional space of contour $$ C $$

2.5.4 Divergence Theorem

Let $$ V $$ represents a volume in three-dimensional space (Fig. 2.17) of boundary $$ S $$. Let $$ {\mathbf{n}} $$ be the outward pointing unit vector normal to $$ S $$. If $$ {\mathbf{v}} $$ is a vector field defined on $$ V $$, then the divergence theorem [30, 31] (also known as Gauss’ theorem) states that

(2.84)

Fig. 2.17

A volume in three-dimensional space with a piecewise smooth boundary $$ S $$

The divergence theorem implies that the net flux of a vector field through a closed surface is equal to the total volume of all sources and sinks (i.e., the volume integral of its divergence) over the region inside the surface. It is an important theorem for fluid dynamics.

The divergence theorem can be used in different contexts to derive many other useful identities (corollaries) [32]. In specific it can be applied to the product of a scalar function, $$ s $$, and a non-zero constant vector, to derive the following important relation:

(2.85)

The divergence theorem is equally applicable to tensors, in which case it is written as

(2.86)

Example 8

Use the divergence theorem to evaluate

where $$ {\mathbf{F}} = \left( {3x + z^{5} } \right){\mathbf{i}} + \left( {y^{2} - \sin\left( {x^{2} z} \right)} \right){\mathbf{j}} + \left(xz + ye^{x^{5}}\right) {\mathbf{k}} $$

and $$ V $$ is a box defined by

with an outward pointing surface

Solution

This is a difficult field to integrate however using the divergence theorem it can be transformed to

where the divergence of $$ {\mathbf{F}} $$ is obtained as

integrating over the box, the integral is evaluated as

2.5.5 Leibniz Integral Rule

The Leibniz integral rule gives a formula for differentiating a definite integral whose limits are functions of the differential variable [33–36]. Let $$ \phi \left( {x,t} \right) $$ represents a function that depends on a space variable $$ x $$ and time $$ t $$. Then Leibniz integral rule can be stated as follows

(2.87)

The meaning of the various terms in Eq. (2.87) can be inferred from Fig. 2.18. The first term on the right side gives the change in the integral because $$ \phi $$ is changing with time $$ t $$, while the second and third terms accounts for the gain and loss in area as the upper and lower bounds are moved, respectively.

Fig. 2.18

Curves showing the spatial distribution of a function at times t and $$ t +\Delta t $$

The three-dimensional form of this formula applied to a volume $$ V\left( t \right) $$ enclosed by a surface $$ S\left( t \right) $$ with its surface elements moving with a velocity $$ {\mathbf{v}}_{s} $$ can be written as

(2.88)

where $$ \phi \left( {t,\,{\mathbf{x}}} \right) $$ is a scalar function of space and time. For a non-moving volume $$ V $$, the equation reduces to

(2.89)

The above equations are also applicable to vectors and tensors.

2.6 Closure

The chapter offered a brief review of vector and tensor operations. In addition the fundamental theorems of vector calculus were presented. The next chapter will rely on information presented in this chapter to derive the conservation equations governing the transfer phenomena of interest in this book.

2.7 Exercises

Exercise 1

Let $$ {\mathbf{v}}_{1} ,{\mathbf{v}}_{2} $$ and $$ {\mathbf{v}}_{3} $$ be three vectors given by

Find:

a.

b.

c.

d.

A unit vector in the direction of $$ \left( {{\mathbf{v}}_{1} + {\mathbf{v}}_{2} + {\mathbf{v}}_{3} } \right) $$

Exercise 2

Let $$ {\mathbf{i}},\,{\mathbf{j}} $$ and $$ {\mathbf{k}} $$ be unit vectors in the $$ x,y, $$ and $$ z $$ direction, respectively, and let $$ {\mathbf{v}} $$ be any vector, which in a Cartesian coordinate system is given by

Prove that

where C is a constant to be determined.

Exercise 3

Find $$ \nabla s $$ if $$ s $$ is the scalar function given by

a.

b.

c.

Exercise 4

If $$ s $$ is a scalar function and $$ {\mathbf{v}} $$ is a vector function, prove the following identities:

a.

b.

c.

d.

Exercise 5

Use Green’s theorem to calculate the area enclosed by an ellipse of semi-major and semi-minor axes $$ a $$ and $$ b $$, respectively.

Exercise 6

Find the Laplacian of the scalar $$ s\,\,\left( {\nabla^{2} s} \right) $$ for the cases when $$ s $$ is given by:

a.

b.

c.

Exercise 7

Verify the divergence theorem for the parallelepiped with centre at the origin and faces in the planes $$ x = \pm 2,y = \pm 1,z = \pm 4 $$ and $$ {\mathbf{v}} $$ given by

a.

b.

c.

Exercise 8

For a surface $$ S $$ representing the upper half of a cube centered at the origin, with one of its vertices at $$ \left( {1,\,1,\,1} \right) $$, and with edges parallel to the axes, verify Stokes’s theorem for the case when the curve $$ C $$ is the intersection of $$ S $$ with the xy plane and the vector $$ {\mathbf{v}} $$ is given by

Exercise 9

Find a function $$ F $$ for which the divergence is the given function $$ K $$ in the following cases:

a.

$$ K\left( {x,\,y,\,z} \right) = \pi $$.

b.

$$ K\left( {x,\,y,\,z} \right) = z^{2} x $$.

c.

Exercise 10

Use the divergence theorem to evaluate the integral $$ \int\limits {\!\!\!}{\int\limits_{\partial F} {\left( {6x{\mathbf{i}} + 4y{\mathbf{j}}} \right) \cdot d{\mathbf{F}}} } $$ where the surface is a sphere defined as $$ \partial F \to x^{2} + y^{2} + z^{2} = 10 $$.

Exercise 11

Let $$ {\mathbf{F}} $$ be a radial vector field defined as $$ {\mathbf{F}} = x{\mathbf{i}} + y{\mathbf{j}} + z{\mathbf{k}} $$ and let $$ C $$ to be a solid cylinder of radius $$ r $$ and height $$ h $$ with its axis coinciding with the $$ x $$-axis and its bottom and top faces located along the $$ x = 0 $$ and $$ x = b $$ plane, respectively. Verify Gauss theorem in both flux and divergence forms.

Exercise 12

Given a square matrix $$ {\mathbf{A}} $$ defined as

decompose it as

and show that

a.

$$ \frac{1}{2}\left( {{\mathbf{A}} + {\mathbf{A}}^{\text{T}} } \right) $$ is symmetric

b.

$$ \frac{1}{2}\left( {{\mathbf{A}} - {\mathbf{A}}^{\text{T}} } \right) $$ is anti-symmetric

Exercise 13

Given two tensors $$ {\mathbf{A}} $$ and $$ {\mathbf{B}} $$ defined as

a.

Calculate the double inner product $$ {\mathbf{A:B}} $$.

b.

Prove that $$ \left( {{\mathbf{A}} + {\mathbf{B}}} \right)^{\text{T}} = {\mathbf{A}}^{\text{T}} + {\mathbf{B}}^{\text{T}} $$ and $$ \left( {{\mathbf{AB}}} \right)^{\text{T}} = {\mathbf{B}}^{\text{T}} {\mathbf{A}}^{\text{T}} $$

c.

Evaluate $$ \nabla \cdot {\mathbf{A}} + \nabla \cdot {\mathbf{B}} $$.

References

1.

Arfken G (1985) Mathematical methods for physicists, 3rd edn. Academic Press, Orlando, FL

2.

Aris R (1989) Vectors, tensors, and the basic equations of fluid mechanics. Dover, New YorkMATH

3.

Crowe MJ (1985) A history of vector analysis: the evolution of the idea of a vectorial system. Dover, New YorkMATH

4.

Marsden JE, Tromba AJ (1996) Vector calculus. WH Freeman, New YorkMATH

5.

Jeffreys H, Jeffreys BS (1988) methods of mathematical physics. Cambridge University Press, Cambridge, England

6.

Morse PM, Feshbach H (1953) Methods of theoretical physics, Part I. McGraw-Hill, New York

7.

Schey HM (1973) Div, grad, curl, and all that: an informal text on vector calculus. Norton, New YorkMATH

8.

Schwartz M, Green S, Rutledge W (1960) A vector analysis with applications to geometry and physics. Harper Brothers, New York

9.

M1 Anton H (1987) Elementary linear algebra. Wiley, New York

10.

Bretscher O (2005) Linear algebra with applications. Prentice Hall, New Jersey

11.

Bronson R (1989), Schaum’s outline of theory and problems of matrix operations. McGraw–Hill, New York

12.

Arnold VI, Cooke R (1992) Ordinary differential equations. Springer-Verlag, Berlin, DE; New York, NY

13.

Horn RA, Johnson CR (1985) Matrix analysis. Cambridge University Press, Cambridge

14.

Brown WC (1991) Matrices and vector spaces. Marcel Dekker, New YorkMATH

15.

Golub GH, Van Loan CF (1996) Matrix Computations. Johns Hopkins, Baltimore

16.

Greub WH (1975) Linear algebra, graduate texts in mathematics. Springer-Verlag, Berlin, DE; New York, NY

17.

Lang S (1987) Linear algebra. Springer-Verlag, Berlin, DE; New York, NY

18.

Mirsky L (1990) An introduction to linear algebra. Courier Dover Publications, New York

19.

Nering ED (1970) Linear algebra and matrix theory. Wiley, New YorkMATH

20.

Spiegel MR (1959) Schaum’s outline of theory and problems of vector analysis and an introduction to tensor analysis. Schaum, New York

21.

Heinbockel JH (2001) Introduction to tensor calculus and continuum mechanics. Trafford Publishing, Victoria

22.

Williamson R, Trotter H (2004) Multivariable mathematics. Pearson Education, Inc, New York

23.

Cauchy A (1846) Sur les intégrales qui s’étendent à tous les points d’une courbe fermée. Comptes rendus 23:251–255

24.

Riley KF, Hobson MP, Bence SJ (2010) Mathematical methods for physics and engineering. Cambridge University Press, Cambridge

25.

Spiegel MR, Lipschutz S, Spellman D (2009) Vector analysis. Schaum’s Outlines, McGraw Hill (USA)

26.

Wrede R, Spiegel MR (2010) Advanced calculus. Schaum’s Outline Series

27.

Katz VJ (1979) The history of stokes’s theorem. Math Mag (Math Assoc Am) 52:146–156MATHCrossRef

28.

Morse PM, Feshbach H (1953) Methods of theoretical physics, Part I. McGraw-Hill, New York

29.

Stewart J (2008) Vector calculus, Calculus: early transcendentals. Thomson Brooks/Cole, Connecticut

30.

Lerner RG, Trigg GL (1994) Encyclopaedia of physics. VHC

31.

Byron F, Fuller R (1992) Mathematics of classical and quantum physics. Dover Publications, New York

32.

Spiegel MR, Lipschutz S, Spellman D (2009) Vector analysis. Schaum’s Outlines, McGraw Hill

33.

Flanders H (1973) Differentiation under the integral sign. Am Math Monthly 80(6):615–627MATHMathSciNetCrossRef

34.

Boros G, Moll V (2004) Irresistible integrals: symbolics, analysis and experiments in the evaluation of integrals. Cambridge University Press, Cambridge, EnglandCrossRef

35.

Hijab O (1997) Introduction to calculus and classical analysis. Springer, New YorkMATH

36.

Kaplan W (1992) Advanced calculus. Addison-Wesley, Reading, MA

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_3

3. Mathematical Description of Physical Phenomena

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

The chapter provides an overview of the conservation principles governing fluid flow, heat and mass transfer, and other related transport phenomena of interest in this book. The physical laws controlling the conservation principles are translated into mathematical relations, written in the form of partial differential equations, representing the needed vehicle for their simulations. First the continuity, momentum, and energy equations (collectively known as the Navier-Stokes equations) expressing the principles of conservation of mass, momentum, and total energy, respectively, are derived. This is followed by the development of a typical conservation equation for a general scalar, vector, or tensor quantity. The mathematical properties of the various terms in these equations are also examined. Moreover, the common practice of writing the conservation equations in a non-dimensional form using dimensionless quantities is explained and some of the dimensionless groups resulting from the application of this procedure, which are very useful for performing parametric studies of engineering problems, are discussed.

3.1 Introduction

Researchers and practitioners of computational fluid dynamics encounter and work with the Navier-Stokes equations [1, 2] almost on daily basis. Many do not realize that these equations are over one hundred seventy years old. Whereas the name Navier-Stokes initially referred to the conservation equation of linear momentum, it is used nowadays to denote collectively the conservation equations of mass, momentum, and energy. These equations can be used to model a wide range of fluid flow configurations, whether it is the flow in a hurricane or in a turbomachine, around an airplane or a submarine, in arteries or in lungs, in pumps or in compressors, the Navier-Stokes equations can describe all these phenomena.

3.2 Classification of Fluid Flows

Fluids, which denote liquids and gases are substances that do not permanently change under a large stress (force per unit area). Whereas a solid resists an applied shear or tangential stress by deforming, a fluid cannot and a shear stress applied to a fluid puts it to motion. Moreover, unlike solids which have well-defined shapes, fluids do not have a definite shape. While gases are fluids that completely fill their domains, liquids are fluids that form a free surface in the presence of a gravitational field.

In analyzing fluid flow phenomena [3–6], attention is focused on what happens at the macroscopic rather than the microscopic scale. It is also assumed that the fluid is a continuum, so that its physical and flow properties are defined at every point in space. Within this assumption, fluid flow behavior can be categorized as either Newtonian or non-Newtonian. Newtonian fluids are characterized by a linear relationship between the shear stress and the shear rate, with the molecular viscosity $$ \mu $$, which is a measure of the ability of a fluid subjected to a stress to resist deformation, representing the slope of the linear function. On the other hand, for non-Newtonian fluids this relationship is nonlinear. Similarly fluid flow can be classified into various classes, such as one-dimensional or multi-dimensional, single phase or multi-phase, steady or unsteady, real (viscous) or ideal (inviscid), compressible or incompressible, turbulent or laminar, and rotational or irrotational, among others. The purpose of these classifications is to simplify the process of analysis and modeling of fluid flow phenomena.

Flows are also classified mathematically according to the partial differential equations describing them. Second order partial differential equations in two independent variables, for example, are categorized as hyperbolic, parabolic, or elliptic. In these equations information travels along two characteristic lines, which may be real and distinct, real and coincident, or complex depending on whether they are of the hyperbolic, parabolic, or elliptic type, respectively. This variation in the nature of the equations necessitates different solution methodologies that should also be recognized by any numerical method used to solve them.

As will be shown in this chapter, fluid flows are governed by the Navier-Stokes equations, which are highly nonlinear second order partial differential equations in four independent variables since, in general, flows are unsteady and three dimensional. Therefore, the above classification does not really apply to them. Nevertheless, the same terminology is used in their categorization as they share many of the properties characterizing second order equations in two independent variables. Transient and supersonic flows are hyperbolic, boundary layer flows are parabolic, and recirculating flows are elliptic. As flows may be subsonic in a certain part of the domain and supersonic in other parts (e.g., flow in a converging-diverging nozzle), or viscous dominated close to walls and essentially inviscid in the core region, it is hard to describe a flow as falling under one of the above three types and in general it is of the mixed type. This categorization is numerically translated into the following: parabolic flows that are affected by upstream locations only, elliptic flows by both upstream and downstream locations, and hyperbolic flows supporting discontinuities in the solution, e.g., shock waves.

3.3 Eulerian and Lagrangian Description of Conservation Laws

The principle of conservation states that for an isolated system certain physical measurable quantities are conserved over a local region. This conservation principle or conservation law is an axiom that cannot be proven mathematically but can be expressed by a mathematical relation. Laws of this type govern several physical quantities such as mass, momentum, and energy (i.e., the Navier-Stokes equations).

The conservation laws involving fluid flow and related transfer phenomena can be mathematically formulated following either a Lagrangian (material volume, MV) or an Eulerian (control volume) approach [7]. In the Lagrangian specification of the flow field (Fig. 3.1a), the fluid is subdivided into fluid parcels and every fluid parcel is followed as it moves through space and time. These parcels are tagged using a time-independent position vector field $$ {\mathbf{x}}_{0} $$, usually selected to be the parcels’ centre of mass at some initial time $$ t_{0} $$, and the flow is described by a function $$ {\mathbf{x}}\left( {t,{\mathbf{x}}_{0} } \right) $$. The path line described by a fluid parcel (Fig. 3.1a) is obtained as the collection of positions occupied at different times.

Fig. 3.1

a Lagrangian and b Eulerian specification of the flow field

On the other hand, the Eulerian approach (Fig. 3.1b) focuses on specific locations in the flow region as time passes. Thus the flow variables are functions of position x and time t and the flow velocity is represented by $$ {\mathbf{v}}\left( {t,{\mathbf{x}}} \right) $$. As the derivative of the position of a fluid parcel $$ {\mathbf{x}}_{0} $$ with respect to time represents its velocity, the two specifications are related by

(3.1)

Based on the above description, changes in the properties of a moving fluid can be measured either on a fixed point in space while fluid particles are crossing it (Eulerian), or by following a fluid parcel along its path (Lagrangian).

3.3.1 Substantial Versus Local Derivative

The derivative (rate of change) of a field variable $$ \phi \left( {t,{\mathbf{x}}\left( t \right)} \right) $$, which may be a scalar or a vector quantity representing density, velocity, temperature, etc., with respect to a fixed position in space is called the Eulerian derivative $$ \left( {\partial \phi /\partial t} \right) $$ while the derivative following a moving fluid parcel is called the Lagrangian, substantial, or material derivative and is denoted by $$ \left( {D\phi /Dt} \right) $$. The substantial derivative of variable $$ \phi $$, which can be derived through application of the chain rule to account for changes induced by all independent variables along the path, is given by

(3.2)

where $$ {\mathbf{v}} $$ is the velocity vector and $$ {\nabla } $$ is the “del” or “gradient” operator defined earlier [6–8].

Equation (3.2) shows that the total rate of change of the function $$ \phi $$ as a fluid parcel moves through a flow field described by its Eulerian specification v from position x at time t to position $$ {\mathbf{x}} + {\mathbf{v}}{\updelta}t $$ at time $$ t + {\updelta}t $$ (Fig. 3.2) is equal to the sum of the local and convective rates of change of $$ \phi $$.

Fig. 3.2

Total rate of change of the field variable ϕ between time t and t + δt

An important example of a material derivative is $$ D{\mathbf{v}}/Dt $$, the rate of change of velocity following the flow, which is the acceleration vector given by

(3.3)

In this book, the conservation laws are described following an Eulerian formulation where the focus is on the flow within a specified region in space, called control volume. This choice is based on the fact that the Eulerian approach follows a field (system) rather than a particle approach, it abandons the tedious and often unnecessary task of tracking individual particles, and focuses attention on what happens at a fixed point (or volume) as different particles go by. Moreover, a critical shortcoming of the Lagrangian approach is its inability to control the domain of interest since fluid parcels travel to where the flow takes them, which may not be the region of interest. This limits the usefulness of the approach as in most fluid flow applications fluid properties in a fixed region are required, e.g., the shear stress on the surface of a moving train, and not the properties of moving material volumes. Nevertheless it should be mentioned that the Eulerian approach introduces into the conservation equations the local effect of transport by the fluid flow through the advective rate of change term, $$ {\mathbf{v}} \cdot \nabla \phi $$, which represents the product of an unknown velocity field and the gradient of an unknown variable field. This nonlinearity leads to the most interesting and most challenging phenomena of fluid flows.

3.3.2 Reynolds Transport Theorem

The conservation laws mentioned above apply to moving material volumes of fluids (Fig. 3.1), and not to fixed points or control volumes. In order to express these laws following an Eulerian approach, there is a need to know the Eulerian equivalent of an integral taken over a moving material volume of fluid. This is provided through the Reynolds transport theorem [9].

The conversion formula differs slightly according to whether the control volume is fixed, moving, or deformable. To derive the formula, let B be any property of the fluid (mass, momentum, energy, etc.) and let $$ b = dB/dm $$ be the intensive value of B (amount of B per unit mass) in any small element of the fluid.

For the arbitrary moving and deformable control volume shown in Fig. 3.1, the instantaneous total change of B in the material volume (MV) is equal to the instantaneous total change of B within the control volume (V) plus the net flow of B into and out of the control volume through its control surface (S). Let $$ \rho $$ denotes the density of the fluid, n the outward normal to the control volume surface, $$ {\mathbf{v}}\left( {t,{\mathbf{x}}} \right) $$ the velocity of the fluid, $$ {\mathbf{v}}_{s} \left( {t,{\mathbf{x}}} \right) $$ the velocity of the deforming control volume surface, and $$ {\mathbf{v}}_{r} \left( {t,{\mathbf{x}}} \right) $$ the relative velocity by which the fluid enters/leaves the control volume [i.e., $$ {\mathbf{v}}_{r} = {\mathbf{v}}\left( {t,{\mathbf{x}}} \right) - {\mathbf{v}}_{s} \left( {t,{\mathbf{x}}} \right) $$], then the Reynolds transport theorem gives

(3.4)

For a fixed control volume, $$ {\mathbf{v}}_{s} = 0 $$ and the geometry is independent of time implying that the time derivative term on the right hand side of Eq. (3.4) can be written using Leibniz rule as

(3.5)

Therefore Eq. (3.4) simplifies to

(3.6)

Applying the divergence theorem to transform the surface integral into a volume integral, Eq. (3.6) becomes

(3.7)

An alternative form of Eq. (3.7) can be obtained by expanding the second term in the square bracket and using the substantial derivative to get

(3.8)

Equation (3.7) or (3.8) can be used to derive the Eulerian form of the conservation laws in fixed regions.

3.4 Conservation of Mass (Continuity Equation)

The principle of conservation of mass [6, 10] indicates that in the absence of mass sources and sinks, a region will conserve its mass on a local level.

Considering the material volume of fluid shown in Fig. 3.3 of mass m, density $$ \rho $$, and velocity v, conservation of mass in material (Lagrangian) coordinate system can be written as

(3.9)

Fig. 3.3

Conservation of mass for a material volume of a fluid of mass m

For $$ B = m $$ the corresponding intensive quantity is $$ b = 1 $$, and based on Eq. (3.8) the equivalent expression of mass conservation in an Eulerian coordinate system is

(3.10)

For the integral given in Eq. (3.10) to be true for any control volume V, the integrand should be equal to zero, giving the differential form of the mass conservation or continuity equation as

(3.11)

The flux form of the continuity equation can be derived using Eq. (3.7) and leading to

(3.12)

Again for the integral in Eq. (3.12) to be true for any control volume V, the integrand should be equal to zero, giving the flux form of the mass conservation or continuity equation as

(3.13)

In the absence of any significant absolute pressure or temperature changes, it is acceptable to assume that the flow is incompressible; that is, the pressure changes do not have significant effects on density. This is almost invariably the case in liquids, and is a good approximation in gases at speeds much less than that of sound. (Note that sound waves are compressible phenomena.) The most important consequence in fluid dynamics is that the mass conservation (continuity) equation can no longer be used to compute the density.

The incompressibility condition indicates that $$ \rho $$ does not change with the flow, which mathematically can be expressed as $$ D\rho /Dt = 0 $$. Using the mass conservation equation given by Eq. (3.11), this is equivalent to saying that the continuity equation for incompressible flow is given by

(3.14)

or in integral form as

(3.15)

Equation (3.15) states that for incompressible flows the net flow across any control volume is zero, i.e., “flow out” = “flow in”.

Note also that $$ D\rho /Dt = 0 $$ does not imply that $$ \rho $$ is the same everywhere (although this happens to be the case in many hydraulic applications), but that $$ \rho $$ does not change along a streamline. To be more accurate, the incompressibility approximation means that each fluid element keeps its original density as it moves. In practice, density differences are commonly encountered in water due to variation in salt concentration and in air due to temperature differences resulting in important buoyancy forces.

3.5 Conservation of Linear Momentum

The principle of conservation of linear momentum [6, 10] indicates that in the absence of any external force acting on a body, the body retains its total momentum, i.e., the product of its mass and velocity vector. Since momentum is a vector quantity, its components in any direction will also be conserved.

For the material volume of a substance, Newton’s Second Law of motion asserts that the momentum of this specific volume can change only in the presence of a net force acting on it, which could include both surface forces and body forces. Therefore, by considering the material volume of fluid shown in Fig. 3.4 of mass m, density $$ \rho $$, and velocity v, Newton’s law in Lagrangian coordinates can be written as

(3.16)

where f is the external force per unit volume acting on the material volume. The term on the right hand side of Eq. (3.16) is a volume integral over material coordinates performed over the volume occupied instantaneously by the moving fluid, thus

(3.17)

Fig. 3.4

Conservation of linear momentum for a material volume of a fluid of mass m

The equivalent expression of Eq. (3.16) in Eulerian coordinates can be written in two different ways known as the conservative and non-conservative forms.

3.5.1 Non-Conservative Form

Noticing that in this case $$ b = {\mathbf{v}} $$, the non-conservative form is obtained by using Eq. (3.8) in the derivation yielding

(3.18)

Again for the integral to be zero over any control volume, the integrand has to be zero. Thus,

(3.19)

Expanding the material derivative of the momentum term and regrouping, the non-conservative form is obtained as

(3.20)

Applying the continuity constraint and expanding the material derivative, the non-conservative form of the momentum equation reduces to

(3.21)

3.5.2 Conservative Form

The conservative (or flux) version is obtained by applying the form of the Reynolds transport theorem given by Eq. (3.7) and is written as

(3.22)

By setting the integrand to zero for the integral to be zero for any volume V, the conservative form of the momentum equation is obtained as

(3.23)

where $$ \rho {\mathbf{vv}} $$ is the dyadic product, described in Chap. 2, which is a special case of tensor product with its divergence being a vector.

Both forms will be used in this book for better describing the discretization concepts and for showing actual implementation details. In the derivations to follow the conservative form will be used. The non-conservative form can be easily obtained from the conservative form at any step by invoking the continuity constraint as explained above.

The full form of the momentum equation is obtained once the external surface and body forces acting on the control volume are specified. The force f is split into two parts one denoted by $$ {\mathbf{f}}_{s} $$ representing the surface forces and the second by $$ {\mathbf{f}}_{b} $$ representing the body forces such that

(3.24)

The details of these forces are given next.

3.5.3 Surface Forces

For the arbitrary macroscopic volume element depicted in Fig. 3.4, the forces acting on its surface are due to pressure and viscous stresses which can be expressed in term of the total stress tensor Σ, as shown in Fig. 3.5. In general there are nine components of stress at any given point; one normal component and two shear components (parallel to the surface that receives the stress) in each coordinate plane. Thus in Cartesian coordinates the stress tensor is given by

(3.25)

where terms of the form $$ \Sigma_{ii} $$ represent normal stresses and $$ \Sigma_{ij} $$ shear stresses. A normal stress can be either a compression, if $$ \Sigma_{ii} \le 0 $$, or a tension, if $$ \Sigma_{ii} \ge 0 $$. The most important compressive normal stress is usually due to pressure rather than to viscous effects. The component $$ \Sigma_{ij} $$ represents the stress acting on face i in the j direction with the direction of face i being positive if the outward normal to the face is in the positive direction.

Fig. 3.5

The surface forces acting on a differential surface element expressed in terms of the stress tensor

In practice the stress tensor is split into two terms such that

(3.26)

where I is the identity tensor of size (3 × 3), p is the pressure, and $$ {\varvec{\uptau}} $$ is the deviatoric or viscous stress tensor. The pressure is the negative of the mean of the normal stresses and is given by

(3.27)

The surface force acting on a differential surface element of area dS and orientation n, as illustrated in Fig. 3.5, is $$ \left( {{\varvec{\Sigma}} \cdot {\mathbf{n}}} \right)dS $$. Applying the divergence theorem, the total surface force acting on the control volume is given by

(3.28)

3.5.4 Body Forces

Body forces, which are presented as forces per unit volume, may also arise due to a variety of effects. There are plenty of examples, but the predominant ones are given next.

3.5.4.1 Gravitational Forces

The force representing the weight of the material volume per unit volume in the presence of a gravitational field is denoted by gravitational force (Fig. 3.6) and given by

(3.29)

where g is the gravitational acceleration vector.

Fig. 3.6

Body forces acting on a differential element

3.5.4.2 System Rotation

When solving fluid flow problems in a rotating frame of reference, the forces arising as a result of the rigid body rotation of the reference frame should be accounted for. These can be viewed as body forces of the form

(3.30)

where $$ \varpi $$ is the angular velocity of the rotating reference frame and r is the position vector (Fig. 3.7). Note that gravitational and centrifugal forces are dependent on position but not on velocity. Thus they can be absorbed into a modified pressure and hence effectively ignored as a separate entity unless they appear in boundary conditions. Coriolis forces however have to be treated explicitly. Other forces, such as magnetic and electric, may be added depending on the particular situation. Due to the many possible types of body forces, no specific type will be adopted in the equations to follow and the generic $$ {\mathbf{f}}_{b} $$ force is retained.

Fig. 3.7

Body forces due to a rigid body rotation in a rotating frame of reference

Substituting the external force f in Eq. (3.23) by its equivalent expression, the general conservative form of the momentum equation is obtained as

(3.31)

3.5.5 Stress Tensor and the Momentum Equation for Newtonian Fluids

To proceed further with the momentum equation, the type of fluid should be known in order to relate the stress tensor $$ {\varvec{\uptau}} $$ to the flow variables. For a Newtonian fluid, the stress tensor is a linear function of the strain rate [2] and is given by

(3.32)

where $$ \mu $$ is the molecular viscosity coefficient, $$ \lambda $$ the bulk viscosity coefficient usually set equal to $$ - \left( {2/3} \right)\mu\,\left( {\lambda = - \left( {2/3} \right)\mu } \right) $$, the superscript T refers to the transpose of $$ \nabla {\mathbf{v}} $$, and I is the unit or identity tensor of size (3 × 3) defined as

(3.33)

The expanded form of the stress tensor in a three-dimensional Cartesian coordinate system can be written as

(3.34)

The divergence of the stress tensor is a vector that can be expressed as

(3.35)

Substituting into Eq. (3.31), the final conservative form of the momentum equation for Newtonian fluids becomes

(3.36)

For later reference the momentum equation is expanded into

(3.37)

and rewritten as

(3.38)

For incompressible flows, the divergence of the velocity vector is zero, i.e., $$ \nabla \cdot {\mathbf{v}} = 0 $$, and the momentum equation reduces to

(3.39)

If the viscosity is constant, the momentum equation can be further simplified. Taking just the first component of the vector equation [Eq. (3.35)], and assuming $$ \mu $$ is constant, the following can be written:

(3.40)

Substitution in Eq. (3.37) yields after simplification

(3.41)

For inviscid flows the viscosity is zero and the momentum equation for incompressible and compressible inviscid flows becomes

(3.42)

3.6 Conservation of Energy

The conservation of energy [6, 10] is governed by the first law of thermodynamics which states that energy can be neither created nor destroyed during a process; it can only change from one form (mechanical, kinetic, chemical, etc.) into another. Consequently, the sum of all forms of energy in an isolated system remains constant.

Considering the material volume shown in Fig. 3.8, of mass m, density $$ \rho $$, and moving with a velocity v. Defining the total energy E of the material volume at time t as the sum of its internal and kinetic energies, then E can be written as

(3.43)

where $$ \hat{u} $$ is the fluid specific internal energy (internal energy per unit mass). The first law of classical thermodynamics applied to the material volume states that the rate of change of the total energy of the material volume is equal to the rate of heat addition and work extraction through its boundaries. Mathematically this is given by

(3.44)

Fig. 3.8

A material volume moves with the particles it encloses

The adopted sign convention is such that heat added to the material volume and work done by the material volume are positive. To apply the Reynolds transport theorem on the material volume, B is set equal to E and b to e (the total energy per unit mass) such that

(3.45)

The net rate of heat transferred to the material element $$ \dot{Q} $$ is the sum of two components. The first component is the rate transferred across the surface of the element $$ \dot{Q}_{S} $$ and the second generated/destroyed (e.g., due to a chemical reaction) within the material volume $$ \dot{Q}_{V} $$. Moreover, the net rate of work done by the material volume $$ \dot{W} $$ is due to the rate of work done by the surface forces $$ \dot{W}_{S} $$ and the rate of work done by the body forces $$ \dot{W}_{b} $$. Thus the first law can be written as

(3.46)

By definition, work is due to a force acting through a distance and power is the rate at which work is done. Therefore the rate of work done by body and surface forces can be represented by

(3.47)

The rate of work due to surface forces can be expanded by replacing $$ {\mathbf{f}}_{S} $$ by its equivalent expression as given in Eq. (3.26) through (3.28). This leads to

(3.48)

After manipulation, $$ \dot{W}_{S} $$ can be rewritten as

(3.49)

If $$ \dot{q}_{V} $$ represents the rate of heat source or sink within the material volume per unit volume and $$ \dot{q}_{S} $$ the rate of heat transfer per unit area across the surface area of the material element, then $$ \dot{Q}_{V} $$ and $$ \dot{Q}_{S} $$ can be written as

(3.50)

Applying the Reynolds transport theorem and substituting the rate of work and heat terms by their equivalent expressions, Eq. (3.46) becomes

(3.51)

Collecting terms together, the above equation is transformed to

(3.52)

For the volume integral in Eq. (3.52) to be true for any control volume, the integrand has to be zero. Thus,

(3.53)

which represents the mathematical description of energy conservation or simply the energy equation written in terms of specific total energy. The energy equation may also be written in terms of specific internal energy, specific static enthalpy (or simply specific enthalpy), specific total enthalpy, and under special conditions in terms of temperature.

3.6.1 Conservation of Energy in Terms of Specific Internal Energy

To rewrite the energy equation [Eq. (3.53)] in terms of specific internal energy, the dot product of the momentum equation [Eq. (3.23)] with the velocity vector is performed resulting in

(3.54)

After some manipulations Eq. (3.54) becomes

(3.55)

Rearranging and collecting terms the following is obtained:

(3.56)

Noticing that the third term on the left side is $$ {\mathbf{v}} \cdot {\mathbf{f}} $$ and replacing f by its equivalent expression, an equation for the flow kinetic energy is obtained as

(3.57)

This equation can be modified and rewritten in the following form:

(3.58)

Subtracting Eq. (3.58) from Eq. (3.53), the energy equation with specific internal energy as its main variable is obtained as

(3.59)

3.6.2 Conservation of Energy in Terms of Specific Enthalpy

Rewriting the energy equation in terms of specific enthalpy is straightforward and follows directly from its definition according to which the specific internal energy and specific enthalpy are related by

(3.60)

Substituting $$ \left( {\hat{h} - p/\rho } \right) $$ for $$ \hat{u} $$ in Eq. (3.59) and performing some algebraic manipulations, the energy equation in terms of specific enthalpy evolves as

(3.61)

3.6.3 Conservation of Energy in Terms of Specific Total Enthalpy

The energy equation in terms of specific total enthalpy can be derived by expressing e in terms of $$ \hat{h}_{0} $$ to get

(3.62)

Then by substituting $$ \left( {\hat{h} - p/\rho } \right) $$ for e in Eq. (3.53) and performing some algebraic manipulations, the energy equation in terms of specific total enthalpy is obtained as

(3.63)

All forms of the energy equation presented so far are general and applicable to Newtonian and non-Newtonian fluids. The only limitation is that they are applicable to a fixed control volume.

3.6.4 Conservation of Energy in Terms of Temperature

To be able to write the energy equation with temperature as the main variable some constraints have to be imposed. Assuming $$ \hat{h} $$ to be a function of p and T, the fluid is expected to be Newtonian. Therefore the derivations to follow are applicable to Newtonian fluids only. If $$ \hat{h} = \hat{h}\left( {p,T} \right) $$, then $$ d\hat{h} $$ can be written as

(3.64)

Using the following ordinary equilibrium thermodynamics relation:

(3.65)

where $$ \hat{V} $$ is the specific volume, the expression for $$ d\hat{h} $$ can be modified to

(3.66)

The left side of the specific enthalpy [Eq. (3.61)], with $$ d\hat{h} $$ given by Eq. (3.66), can be rewritten in terms of T as

(3.67)

Substituting Eq. (3.67) into Eq. (3.61) gives the energy equation with T as its main variable as

(3.68)

The above equation is equivalently given by

(3.69)

The heat flux $$ \dot{q}_{S} $$ appearing in all forms of the energy equation represents heat transfer by diffusion, which is a phenomenon occurring at the molecular level and is governed by Fourier’s law according to

(3.70)

where k is the thermal conductivity of the substance. The above equation states that heat flows in the direction of temperature gradient and assumes that the material has no preferred direction for heat transfer with the same thermal conductivity in all directions, i.e., the medium is isotropic. However some solids are anisotropic for which Eq. (3.70) is replaced by

(3.71)

where $$ {\varvec{\upkappa}} $$ is a second order symmetric tensor called the thermal conductivity tensor. Consequently, the heat flux in anisotropic medium is not in the direction of the temperature gradient. In the derivations to follow the medium is assumed to be isotropic and Eq. (3.70) is applicable. Replacing $$ \dot{q}_{s} $$ using Fourier’s law, the energy equation, Eq. (3.69), becomes

(3.72)

The expression for $$ \left( {{\varvec{\uptau}}:\nabla {\mathbf{v}}} \right) $$ in terms of the flow variables in a three-dimensional Cartesian coordinate system is given by

(3.73)

Defining $$ \Psi $$ and $$ \Phi $$ as

(3.74)

(3.75)

The energy equation in terms of temperature reduces to

(3.76)

For later reference the energy equation is expanded to

(3.77)

and rewritten as

(3.78)

The energy equation is rarely solved in its full form and depending on the physical situation several simplified versions can be developed. The dissipation term Φ has negligible values except for large velocity gradients at supersonic speeds. Moreover, for incompressible fluids the continuity equation implies that $$ \Psi = 0 $$ and because the density is constant it follows that $$ \left( {\partial \left( {Ln\rho } \right)} \right/\partial \left( {LnT} \right)) = 0 $$. Therefore the energy equation [Eq. (3.77)] for incompressible fluid flow is simplified to

(3.79)

Equation (3.79) is also applicable for a fluid flowing in a constant pressure system. For the case of a solid, the density is constant, the velocity is zero, and if changes in temperature are not large then the thermal conductivity may be considered constant, in which case the energy equation becomes

(3.80)

For ideal gases $$ \left( {\partial \left( {Ln\rho } \right)} \right/\partial \left( {LnT} \right)) = - 1 $$ and the energy equation for compressible flow of ideal gases reduces to

(3.81)

If viscosity is neglected (i.e. the flow is inviscid), Eq. (3.81) is further simplified to

(3.82)

3.7 General Conservation Equation

From the above, the governing equations describing the conservation of mass, momentum, and energy are written in terms of specific quantities or intensive properties, i.e., quantities expressed on a per unit mass basis. The momentum equation, for example, expressed the principle of conservation of linear momentum in terms of the momentum per unit mass, i.e., velocity. The same type of conservation equation may be applied to any intensive property $$ \phi $$, e.g., concentration of salt in a solution or the mass fraction of a chemical species. The variation of $$ \phi $$ in the control volume over time can be expressed as a balance equation of the form

For the fixed control volume shown in Fig. 3.9, the change of $$ \phi $$ over time within the material volume can be written using the Reynolds transport theorem as

(3.83)

where $$ \rho $$ is the fluid density and V the volume of the control volume of surface area S. The term $$ \rho {\mathbf{v}}\phi $$ represents the transport of $$ \phi $$ by the flow field and is denoted by the convective flux, i.e.,

(3.84)

Fig. 3.9

Arbitrary fixed control volume

The second term represents variation of $$ \phi $$ due to physical phenomena occurring across the control volume surface. For the physical phenomena of interest in this book, the mechanism causing the influx/out flux of $$ \phi $$ is due to diffusion, which is produced by molecular collision and is designated by $$ {\mathbf{J}}_{diffusion}^{\phi } $$. Denoting the diffusion coefficient of $$ \phi $$ by $$ \Gamma ^{\phi } $$, the diffusion flux may be written as

(3.85)

and Term II becomes

(3.86)

where n is the outward unit vector normal to the surface and the negative sign is due to the adopted sign convention (i.e., inward flux is positive). Term III can be written as

(3.87)

where $$ Q^{\phi } $$ is the generation/destruction of $$ \phi $$ within the control volume per unit volume, which is also called the source term. Thus the conservation equation can be expressed as

(3.88)

which can be rearranged into

(3.89)

For the integral to be zero for any control volume, the integrand has to be zero giving the conservation equation in differential form as

(3.90)

For later reference the above equation may be rewritten as

(3.91)

where the total flux $$ {\mathbf{J}}^{\phi } $$ is the sum of the convective and diffusive fluxes given by

(3.92)

The final form of the general conservation equation, Eq. (3.90), for the transport of a property $$ \phi $$ is expressed as

(3.93)

By comparing Eq. (3.93) to the various conservation equations derived earlier, it can be easily inferred that by assigning the right values for $$ \phi ,\Gamma ^{\phi } $$, and $$ Q^{\phi } $$, Eq. (3.93) is a general equation that can represent any of the conservation equations. This is a very important observation that will reduce the necessary developments of the numerical techniques in the coming chapters by concentrating on the general equation [Eq. (3.93)] rather than the individual conservation equations.

3.8 Non-dimensionalization Procedure

The differential equations representing conservation laws are rarely solved using dimensional variables. The common practice is to write these equations in a non-dimensional form using dimensionless quantities that are obtained through the use of proper characteristic scales. The use of non-dimensional variables has several advantages. It allows reducing the number of appropriate parameters for the problem considered and helps revealing the relative magnitude of the various terms in the conservation equation and consequently those that can be neglected. This simplifies the equation to be solved and leaves only terms of similar order of magnitude, which results in better numerical accuracy. In addition, the generated solution will be applicable to all dynamically similar problems.

A dimensional variable is transformed into a non-dimensional one by dividing the variable by a quantity (composed of one or more physical properties) that has the same dimension as the original variable. For example spatial coordinates can be divided by a characteristic length; velocity can be divided by a characteristic velocity or a combination of quantities $$ \left( {\mu_{ref} /\rho_{ref} l_{ref} } \right) $$ that have collectively the same units as velocity (m/s); pressure is usually divided by a reference dynamic pressure $$ \left( {\rho_{ref} \left| {{\mathbf{v}}_{ref} } \right|^{2} } \right) $$; time can be divided by the ratio of a characteristic length to a reference velocity $$ \left( {l_{ref} /\left| {{\mathbf{v}}_{ref} } \right|} \right) $$, and so on. The best way to fully understand how to write equations in non-dimensional form is through an example. For that purpose, an incompressible viscous flow with constant viscosity and thermal conductivity, and with body forces acting in the y-direction (i.e., the gravitational acceleration is given by $$ {\mathbf{g}} = \left( {0, - g,0} \right) $$) is considered. The equations governing conservation of mass, momentum, and energy in a three-dimensional Cartesian coordinate system with no heat generation are given by

(3.94)

(3.95)

(3.96)

(3.97)

(3.98)

When body forces are of negligible magnitude in comparison with other forces, the term $$ \rho {\mathbf{g}} $$ can be set to zero and removed from the equations. In such situation, the flow field is independent of the temperature field and solution for the velocity field can be established separately followed by the solution to the temperature field. However for a flow to exist the fluid should be forced through the domain. Therefore the fluid should possess an inlet velocity. This velocity becomes an important parameter (the characteristic velocity) when writing the equations in non-dimensional forms and the heat transfer mechanism, if any, is said to occur by forced convection.

On the other hand, when a flow field is naturally established due to a temperature difference in the domain, body forces cannot be neglected. In such situations, variations in temperature cause variations in density (as mentioned earlier), which give rise to buoyancy forces that drive the flow. In this case the transfer of heat is stated to happen by natural convection. As the flow is initiated naturally, a characteristic velocity is not apparent and cannot be part of the dimensionless number since its scale is not known. Therefore in order to write the velocity in a non-dimensional form, a combination of physical quantities that has the same dimension as a velocity should be used. The following discussion assumes a natural convection problem.

If the difference in temperature $$ \Delta T = T - T_{\infty } $$ (where $$ T_{\infty } $$ is a reference temperature between the minimum and maximum temperature in the domain, usually taken as the average value) is small such that terms of order $$ \Delta T^{2} $$ or higher can be neglected, then the value of density at any temperature T can be written as a function of its value at the reference temperature $$ T_{\infty } $$ using a truncated Taylor series expansion as

(3.99)

where terms of order $$ \Delta T^{2} $$ or higher are omitted. Introducing the coefficient of volume expansion $$ \beta $$ defined as

(3.100)

the equation for density (or equation of state) becomes

(3.101)

which is known in the literature by the Boussinesq approximation [11]. Using this expression for $$ \rho $$ in the body force term only and denoting the constant density value by $$ \rho $$ to simplify the notation, the y-momentum equation is transformed to

(3.102)

This clearly shows that in solving natural convection problems the momentum and energy equations are coupled together necessitating a simultaneous solution of both equations.

The non-dimensional forms of the conservation equations are obtained by defining the following dimensionless parameters:

(3.103)

where L is a characteristic length, $$ \mu $$ the dynamic viscosity of the fluid, $$ T_{max} $$ the maximum temperature in the domain, and the over $$ \wedge $$ is used to designate non-dimensional quantities. The various expressions in the conservation equations are written in terms of the new variables as described next. The procedure is explained by considering a typical term from each category.

Typical term in the continuity equation:

(3.104)

Typical terms in the momentum equations:

(3.105)

(3.106)

(3.107)

(3.108)

(3.109)

Typical terms in the energy equation:

(3.110)

(3.111)

(3.112)

Substituting terms by their equivalent expressions, the non-dimensional forms of the continuity, momentum, and energy equations are obtained as

(3.113)

(3.114)

(3.115)

(3.116)

(3.117)

where Gr is the Grashof number, Pr is the Prandtl number, and v the kinematic viscosity defined as

(3.118)

The Grashof and Prandtl numbers [12–14] are dimensionless groups formed of a combination of the involved physical properties. Therefore the number of parameters affecting the solution was reduced to two and solutions can be generated for different values of these two parameters. Moreover any single solution will be valid for many combinations of the physical properties of which these two numbers are composed, as long as these combinations result in the Gr and Pr values for which the solution was obtained. The physical significance of these two dimensionless numbers and others that may arise when writing the conservation equations in non-dimensional forms using other dimensionless parameters under different conditions is discussed next.

3.9 Dimensionless Numbers

Writing the conservation equations in non-dimensional forms, results in dimensionless numbers that are very useful for performing parametric studies of engineering problems. For incompressible viscous flow, the dimensionless parameters governing natural convection heat transfer were reduced to the two dimensionless numbers Gr [12–14] and Pr [12–14]. Under different conditions (e.g., compressible flows, Porous flows, etc.) other types of fluid forces and dissipation terms may be included in the governing equations resulting in different non-dimensional groups. For flow in porous media, for example, Darcy number $$ \left( {Da} \right) $$ [15, 16] emerges as an important parameter, for a free surface flow the Weber number $$ \left( {We} \right) $$ [17, 18], for an open channel flow the Froude number $$ \left( {Fr} \right) $$ [19], for a compressible flow the Mach number $$ \left( M \right) $$ [20], and so on. Some of the most important dimensionless groups are discussed below.

3.9.1 Reynolds Number

The Reynolds number $$ \left( {Re} \right) $$ [12, 13] is defined as

(3.119)

and may be interpreted as a measure of the relative importance of advection (inertia) to diffusion (viscous) momentum fluxes. If the momentum fluxes are in the same direction then the Reynolds number reveals the boundary layer characteristics of the flow. If the fluxes are defined such that the diffusion is in the cross stream direction, then as shown in Fig. 3.10 Re conveys the flow regime (i.e. laminar, transitional, or turbulent).

Fig. 3.10

Schematic of the flow over a flat plate showing the laminar, transitional, and turbulent flow regimes based on the value of Re

An example showing the flow field for different values of Reynolds number is depicted in Fig. 3.11. It represents a driven flow in a square cavity of side L generated by the velocity U imparted to its top wall. The streamlines shown in Fig. 3.11 indicates that the strength of the flow increases as $$ Re = \rho UL/\mu $$ increases.

Fig. 3.11

Streamlines at increasing values of Reynolds number for driven flow in a square cavity

3.9.2 Grashof Number

As derived above the Grashof number [12–14] is given by

(3.120)

The Grashof number represents the ratio of buoyant to viscous forces. It plays in natural convection the same role played by the Reynolds number in forced convection. An example showing the effect of Grashof number is depicted in Fig. 3.12. The physical situation represents natural convection heat transfer in the annulus between a hot circular cylinder and its cold square enclosure. Isotherms displayed in the figure are seen to become more distorted at higher values of Gr due to higher natural convection effects caused by a stronger flow field.

Fig. 3.12

Isotherms at increasing values of Grashof number for natural convection in the annulus between eccentric horizontal hot circular and cold square cylinders

3.9.3 Prandtl Number

The Prandtl number [12–14] is defined as the ratio of momentum diffusivity (kinematic viscosity v) to thermal diffusivity $$ \left( \alpha \right) $$, i.e.,

(3.121)

The Prandtl number represents the ratio of hydrodynamic boundary layer to thermal boundary layer. As displayed in Fig. 3.13, the thermal boundary layer is larger than the hydrodynamic boundary layer for $$ Pr\, < \,1 $$ (Fig. 3.13a) and the opposite is true for $$ Pr > 1 $$ (Fig. 3.13b). Both layers coincide for $$ Pr = 1 $$.

Fig. 3.13

The thermal and hydrodynamic boundary layer thicknesses for a $$ Pr < 1 $$ and b $$ Pr > 1 $$

For the driven flow in a square cavity problem presented above, isotherms over the domain are depicted in Fig. 3.14 for different values of Pr while holding Re constant at 100. The increase in convection over conduction as Pr increases can be easily inferred from the plots.

Fig. 3.14

Isotherms at increasing values of Prandtl number for driven flow in a square cavity $$ \left( {Re = 100} \right) $$

3.9.4 Péclet Number

The Péclet number [5] is defined as the ratio of the advective transport rate of a physical quantity to its diffusive transport rate. For the case of heat transfer, the Péclet number is given by

(3.122)

In this situation the Pe is equivalent to the product of the Reynolds number and the Prandtl number. An example of the effects of Pe is shown in Fig. 3.15, where isotherms over a flat hot plate are displayed at different values of Péclet number. Heat transfer is seen to be dominated by conduction at low values of Pe with convection gaining increasing importance as Pe increases to become clearly the dominant heat transfer mode at $$ Pe = 1000 $$.

Fig. 3.15

Isotherms at increasing values of Péclet number for fluid flow over a flat plate maintained at a hot uniform temperature

For mass transport, the Péclet number is given by

(3.123)

where D is the mass diffusivity and Sc the Schmidt number. In this case Pe is equivalent to the product of the Reynolds number and the Schmidt number.

A large Péclet number indicates low dependence of the flow on downstream locations and high dependence on upstream locations. Therefore simpler computational models can be adopted for simulating situations with high Péclet numbers.

3.9.5 Schmidt Number

The Schmidt number [14] is defined as

(3.124)

The Schmidt number in mass transfer is the counterpart of the Prandtl number in heat transfer. It represents the ratio of the momentum diffusivity $$ \left( v \right) $$ to mass diffusivity $$ \left( D \right) $$. Physically, the Sc relates the thicknesses of the hydrodynamic and mass transfer boundary layers. An example showing the effect of Schmidt number is shown in Fig. 3.16.

Fig. 3.16

Iso-concentrations at increasing values of Schmidt number (other parameters held fixed) for natural convection mass transfer in the annulus between concentric horizontal cylinders of rhombic cross sections with larger solute concentration on the inner wall

The figure above represents natural convection mass transfer in the annulus between two horizontal pipes of rhombic cross sections. The solute concentration is higher along the inner wall of the enclosure. The concentration non-uniformity causes variations in density establishing a flow field. The strength of the flow increases with increasing Sc values as manifested by the higher distortion of iso-concentration lines that indicates an increase in convection mass transfer over diffusion mass transfer, which dominates at low Sc values.

3.9.6 Nusselt Number

The Nusselt number [12–14] expressed as

(3.125)

is the dimensionless form of the convection heat transfer coefficient h and provides a measure of the convection heat transfer at a solid surface. The Nusselt number does not arise as a dimensionless group when writing the conservation equations in non-dimensional forms; rather, it is widely used to report convection heat transfer data.

3.9.7 Mach Number

The Mach number $$ \left( M \right) $$ [20] is defined as the ratio of speed of an object moving through a fluid and the local speed of sound [20]. Mathematically it is written as

(3.126)

where $$ \left| {\mathbf{v}} \right| $$ is the local magnitude of the fluid velocity relative to the medium in which it is flowing and a is the speed of sound. The general equation for the speed of sound is given by

(3.127)

For an ideal gas, it reduces to

(3.128)

where $$ \gamma $$ is the ratio of specific heat at constant pressure to specific heat at constant volume $$ \left( {c_{p} /c_{v} } \right) $$ and R is the gas constant.

Flows for which the Mach number is less than 0.2 can be treated as incompressible. For $$ M < 1 $$ the flow is called subsonic, for $$ M = 1 $$ sonic, for $$ 1 < M < 5 $$ supersonic, and for $$ M > 5 $$ hypersonic. Moreover, a flow accelerating from subsonic to supersonic is called a transonic flow. The value of Mach number (less than 1 or greater than 1) at the boundaries of a domain dictates the number of required boundary conditions there.

Examples of subsonic, transonic, and supersonic flow fields are presented in Fig. 3.17 via Mach contours. The physical situation represents a fluid flowing over a circular arc bump with a maximum curvature of 10 % the channel height in the subsonic and transonic cases and of 4 % in the supersonic case. The change in the flow type from elliptic to hyperbolic (with discontinuities in the form of shock waves) as the Mach number increases from subsonic $$ \left( {M < 1} \right) $$ to supersonic $$ \left( {M > 1} \right) $$ is apparent.

Fig. 3.17

Mach contours for the flow over a circular arc bump at a subsonic, b transonic, and c supersonic speeds

3.9.8 Eckert Number

The Eckert number $$ \left( {Ec} \right) $$ [21] is a dimensionless number relating the kinetic energy of the flow to its enthalpy and is computed as

(3.129)

where $$ \Delta T $$ is a characteristic temperature difference. This dimensionless number appears as a factor multiplying the viscous dissipation term $$ \Phi $$, when non-dimensionalizing the compressible energy equation. A large value of Ec indicates high viscous dissipation occurring at high speed of the flow (high kinetic energy). For small Eckert number $$ \left( {Ec \ll 1} \right) $$ several terms in the energy equation become negligible (e.g., viscous dissipation, body forces, etc.). This reduces the energy equation to its incompressible form (i.e., a balance between conduction and convection).

3.9.9 Froude Number

The Froude number $$ \left( {Fr} \right) $$ [19] is a dimensionless number defined as the ratio of a characteristic velocity $$ \left( U \right) $$ to a gravitational wave velocity $$ \left( {\sqrt {gL} } \right) $$ as

(3.130)

It is a measure of the resistance of partially immersed objects moving through fluids, with higher $$ \ {Fr} $$ values indicating higher fluid resistance.

For the free-surface flow shown in Fig. 3.18, the nature of the flow is dictated by the value of Froude number. For $$ Fr > 1 $$ the flow is supercritical and for $$ Fr < 1 $$ it is subcritical. The flow at the interface between the two regions, known as the “hydraulic jump”, is just critical and is characterized by a Froude number value of 1.

Fig. 3.18

A free surface flow showing the supercritical, critical, and subcritical regions

3.9.10 Weber Number

The dimensionless Weber number $$ \left( {We} \right) $$ [17, 18] is defined as

(3.131)

where U (m/s) and L (m) are the characteristic velocity and length, respectively, and $$ \sigma $$ the surface tension (N/m). The Weber number, which represents the ratio of inertia to surface tension forces, is helpful in analyzing multiphase flows involving interfaces between two different fluids, with curved surfaces such as droplets and bubbles.

3.10 Closure

This chapter has shown that many physical phenomena can be modeled through conservation equations. These equations are derived from first principles by writing balances over a finite volume. It was also shown that the conservation equations governing the transport of mass, momentum, energy, and other specific quantities have a common form embodied in the general scalar transport equation. This equation has transient, convection, diffusion and source terms. Each term brings a characteristic contribution to the equation that needs to be reproduced by the discretization procedure.

3.11 Exercises

Exercise 1

By comparing the continuity, momentum, and energy equations with the general scalar transport equation, derive expressions for $$ \phi $$, $$ \Gamma ^{\phi } $$ and $$ S^{\phi } $$.

Exercise 2

Show that for an incompressible flow of constant viscosity the following holds:

Exercise 3

A steady incompressible flow field is defined by the following velocity vector:

(a)

Verify that it satisfies the continuity equation.

(b)

Assuming constant viscosity $$ \mu $$, calculate the viscous stress tensor $$ {\varvec{\uptau}} $$.

(c)

Denoting the fluid density by $$ \rho $$ and neglecting body forces, develop an equation for the pressure gradient.

Exercise 4

The vorticity $$ \omega $$ of a flow field is defined as the curl of the velocity vector, i.e.,

Using the above definition of vorticity, show that for an incompressible fluid, the following relation between the velocity and vorticity vectors holds:

Exercise 5

A flow is said to be irrotational if its vorticity (defined in Exercise 4 above) is zero, i.e., $$ \omega = 0 $$. Show that for a steady two dimensional incompressible irrotational flow the velocity field satisfies the following Laplace equation

Exercise 6

Consider a two-dimensional square enclosure of side L. The enclosure is filled with an incompressible fluid of viscosity $$ \mu $$ and density $$ \rho $$. The top side of the enclosure is covered with an infinite horizontal wall moving with a constant velocity U. The other sides are fixed in place. Due to the motion of the top wall a flow field is established within the enclosure. Using appropriate dimensionless variables, write the simplified momentum equation for the flow field in dimensionless form showing that the Reynolds number $$ \left( {Re = \rho UL/\mu } \right) $$ is the only dimensionless group affecting the flow.

Exercise 7

Consider the steady two dimensional mixed convection heat transfer in a vertical rectangular channel of width W. A cold fluid of density $$ \rho_{in} $$ and temperature $$ T_{in} $$ enters the channel with a velocity $$ V_{in} $$. As it flows vertically upward, the fluid is heated by the duct walls, which are maintained at the uniform hot temperature $$ T_{w} $$. Taking buoyancy forces into consideration through the Boussinesq approximation and using the following dimensionless variables

write the conservation equations of mass, momentum, and energy in dimensionless forms. What are the dimensionless groups governing the flow and heat transfer in the channel? What does each of them represent?

Exercise 8

Estimates the Reynolds number of the following flows:

(a)

Water flowing at a speed of 15 km/hr over a whale 10 m long.

(b)

Air flowing at a speed of 800 km/hr over the wing of an F16 airplane of mean chord length 3.450336 m.

(c)

Glycerine of dynamic viscosity 0.96 kg/ms and density 1258 kg/m³ flowing at a speed of 2.8 m/s in a pipe inclined at 25° to the horizontal and of diameter 250 mm.

Exercise 9

Starting from the incompressible version of the Navier-Stokes equations derive simplified equations based on the following assumptions:

(a)

Viscous effects are much more significant than any effects of fluid acceleration, i.e.,

which corresponds to $$ Re = \rho UL/\mu \ll 1 $$ (Stokes Equations).

(b)

Inertial effects dominate and viscous effects are considered to be negligible throughout the flow domain, i.e.,

which corresponds to $$ Re = \rho UL/\mu \gg 1 $$ (Euler equations).

(c)

Derive the Bernoulli equation from momentum conservation with the following hypothesis: one dimensional steady state conditions of a frictionless fluid $$ \mu = 0 $$.

References

1.

Navier CLMH (1823) Mem Acad R Sci Paris 6:389–416

2.

Stokes GG (1845) Trans Camb Phil Soc 8:287–305

3.

Hauke G (2008) An Introduction to Fluid Mechanics and transport phenomena. Springer, New YorkMATHCrossRef

4.

Ferziger JH, Peric M (2002) Computational methods for fluid dynamics. Springer, New YorkMATHCrossRef

5.

Patankar SV (1980) Numerical heat transfer and fluid flow. Hemisphere Publishing Corporation, USAMATH

6.

Bird RB, Stewart WE, Lightfoot EN (2006) Transport phenomena, 2nd edn. Wiley, USA

7.

Falkovich G (2011) Fluid mechanics (A Short Course for Physicists). Cambridge University Press, Cambridge

8.

Emanuel G (2000) Analytical fluid dynamics. CRC Press, Boca Raton

9.

Reynolds O (1903) Papers on mechanical and physical subjects-the sub-mechanics of the universe. Collected Work, vol III, Cambridge University Press, Cambridge

10.

Fay JA (1994) Introduction to fluid mechanics. MIT Press, Cambridge MassachussetsMATH

11.

Boussinesq J (1897) Theorie de l’ecoulement tourbillonnant et tumulueux des liquides and les lits rectilignes a grande section. Gauthier-Villars et Fils, Des Comptes Rendus des Seances de L’academie des Sciences, Paris

12.

Cengel YA (2003) Heat and mass transfer: a practical approach, 3rd edn. McGraw-Hill, Boston

13.

Incropera FP, DeWitt DP (2007) Fundamentals of heat and mass transfer, 6th edn. Wiley, Hoboken

14.

Bejan A (1984) Convection heat transfer. Wiley, USAMATH

15.

Moukalled F, Darwish M (2013) Double diffusive natural convection in a porous rhombic annulus. Numer Heat Transfer Part A: Appl 65(5):378–399CrossRef

16.

Moukalled F, Darwish M (2010) Natural convection heat transfer in a porous rhombic annulus. Numer Heat Transfer, Part A: Appl 58(2):101–124CrossRef

17.

Frohn A, Roth N (2000) Dynamics of droplets. Springer, New YorkMATHCrossRef

18.

Day P, Manz A, Zhang Y (2012) Microdroplet technology: principles and emerging applications in biology and chemistry. Springer, New YorkCrossRef

19.

Chanson H (2004) Hydraulics of open channel flow: an introduction, 2nd edn. Butterworth–Heinemann, Oxford

20.

Oosthuizen PH, Carscallen WE (1997) Compressible fluid flow. McGraw-Hill, Singapore

21.

Kreith F, Bohn MS (1993) Principles of heat transfer, 5th edn. West Publishing Company, USA

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_4

4. The Discretization Process

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter introduces the different steps of the discretization process, which include: (i) modeling of the geometric domain and the physical phenomena of interest; (ii) discretization of the modeled geometric domain into a grid or mesh that forms the computational domain (this process, also known as meshing or domain discretization, results in a set of non-overlapping elements, denoted also by cells, that cover the computational domain); (iii) numerical or equation discretization that transforms the set of conservation partial differential equations governing the physical processes into an equivalent system of algebraic equations defined over each of the elements of the computational domain; and (iv) the solution of the resulting set of equations using an iterative solver to yield an intermediate or final solution field. Throughout the chapter, computer implementation issues are introduced.

4.1 The Discretization Process

The numerical solution of a partial differential equation consists of finding the values of the dependent variable ϕ at specified points from which its distribution over the domain of interest can be constructed. These points are called grid elements, or grid nodes and result from the discretization of original geometry into a set of non overlapping discrete elements, a process known as meshing. The resulting nodes or variables are generally positioned at cell centroids or at vertices depending on the adopted discretization procedure. In all methods the focus is on replacing the continuous exact solution of the partial differential equation with discrete values. The distribution of ϕ is hence discretized, and it is appropriate to refer to this process of converting the governing equation into a set of algebraic equations for the discrete values of ϕ as the discretization process and the specific methods employed to bring about this conversion as the discretization methods. The discrete values of ϕ are typically computed by solving a set of algebraic equations relating the values at neighboring grid elements to each other; these discretized or algebraic equations are derived from the conservation equation governing ϕ. Once the values of ϕ are computed, the data is processed to extract any needed information. The various stages of the discretization process are illustrated in Fig. 4.1.

Fig. 4.1

The discretization process

Figure 4.2 shows the process applied to the study of heat transfer from a microprocessor connected to a heat sink with a copper base that acts as a heat spreader. The example of Fig. 4.2 will be used to present various concepts related to the discretization process. Since the intention is to introduce a numerical technique for solving the physical processes of interest and since the method has to be implemented in a computer program, the discretization process will be explained along that spirit. For example, reference will be made to how to store values in a code as related to interior elements, boundary elements, variables, etc. Throughout the book a Matlab® based program denoted by “uFVM” will be used as a development vehicle to present various details relating to the implementation of these methods. Furthermore OpenFOAM®, a very popular finite volume-based open source code will also be presented both from a user and a developer perspective, again with the aim of moving from the numerics to the implementation details.

Fig. 4.2

An illustration of the discretization process

4.1.1 Step I: Geometric and Physical Modeling

Modeling of physical phenomena is in a way at the heart of the scientific enterprise. A physical phenomenon cannot generally be considered as understood unless it can be mathematically formulated, and this formulation tested and validated. For our purpose two levels of modeling are performed, one in relation to the geometry of the physical domain and a second in relation to the physical phenomena of interest. At both levels details that are neither relevant nor of interest are ignored or simplified. For example a three dimensional domain could be turned into a two dimensional depiction, or symmetry can be taken into account to decrease the size of the study domain. In some cases, physical components may be removed and replaced with appropriate mathematical representations.

In the example of Fig. 4.2 a microprocessor is connected to a heat sink with a copper base that acts as a heat spreader. A first model of this system simplifies both its physics and its geometry. The heat sink and processor are replaced by boundary conditions that specify the estimated temperature of the heat sink and the expected operating temperature of the processor, respectively. The physical domain is modeled as a two dimensional computational domain since the temperature variation through the thickness of the heat sink will be minimal. For a steady state solution of the heat flow and temperature distribution in the copper base, only heat conduction is considered. The result of the modeling process is a system of linear (or non-linear if k depends on T) partial differential equations, which in this case involves a simplified form of the energy equation given by

(4.1)

where k is the conductivity of the heat spreader base, and $$ \dot{q} $$ is the heat source/sink per unit volume.

4.1.2 Step II: Domain Discretization

The geometric discretization of the physical domain results in a mesh on which the conservation equations are eventually solved. This requires the subdivision of the domain into discrete non-overlapping cells or elements that completely fill the computational domain to yield a grid or mesh system. This is accomplished by a variety of techniques resulting in a wide range of mesh types. These meshes are classified according to several characteristics: structure, orthogonality, blocks, cell shape, variable arrangement, etc. In all cases the mesh is composed of discrete elements defined by a set of vertices and bounded by faces. For the mesh to be a useful platform for equation discretization, information related to the topology of the mesh elements, in addition to some derived geometric information, are needed. These include element to element relations, face to elements relations, geometric information of the surfaces, element centroid and volume, face centroid, area and normal direction, etc. This information is usually inferred from the basic mesh data. For certain mesh topologies, details about the mesh can be easily deduced from the element indices as in structured grids, while for others it has to be constructed and stored in lists for later retrieval, as is the case with unstructured grids.

Consider the simple domain shown in Fig. 4.3a. The domain consists of a volume (area for the two dimensional case) and boundaries that account for the heating or cooling of the microprocessor, a heat sink, and the heat spreader base. The domain is shown discretized with a simple mesh in Fig. 4.3b. The mesh boundary is divided into three patches of boundary faces that are assigned numbers, i.e., Patch#1, Patch#2, and Patch#3. These patches are used to define the physical boundary conditions for the problem at hand. The mesh consists of 25 non-overlapping elements whose geometry is defined by 40 points (vertices of the cells). The elements are also bounded by 66 faces (lines in a two dimensional case), 34 of which are interior faces. The algebraic equations that result from the discretization of the governing equations, as will be explained in step III, are described for each element in the computational domain with the solution expressed as an element field with values defined at the centroid of each element. In this example the elements have a square shape, though other shapes could have been used (e.g., triangular elements, as shown in Fig. 4.3c).

Fig. 4.3

a Computational domain; b computational mesh (quadrilateral); c computational mesh (triangular)

The mesh can be described from different perspectives. At the most elementary level it is a list of vertices or points representing locations in one dimensional, two dimensional, or three dimensional spaces. The mesh also represents the discretized domain subdivided into non-overlapping elements, which can be of arbitrary convex polyhedral shapes. Elements are completely bounded by faces that are generally shared by neighboring elements, except at the boundaries. Elements can be defined either in terms of the points that delimit them or in terms of the faces that bound them. The mesh faces, which are stored in a list, are of two types: (i) interior faces that are shared by (or connect) two elements, and (ii) boundary faces that coincide with the domain boundary; these boundary faces have only one contiguous element. While interior faces are derived from information related to the element topology, it is essential to provide boundary faces as they define the domain physical boundary. In two dimensions faces are described in terms of their defining points. In three dimensions the defining points describe edges that bound the face. The direction of the normal to an interior face is usually defined based on the topology of the neighboring elements. On the other hand, the direction of the normal to a boundary face always points outward of the domain. Figure 4.4 shows some of the components (vertices, faces, and elements shown in Fig. 4.4a–c respectively) of a mesh. Furthermore the boundary faces are organized into lists of faces based on the boundary patch to which they belong.

Fig. 4.4

a Mesh vertices, b faces, and c elements

4.1.3 Mesh Topology

During discretization, the partial differential equations are integrated over each element in the mesh resulting in a set of algebraic equations with each one linking the value of the variable at an element to the values at its neighbors. The algebraic equations are then assembled into global matrices and vectors and the coefficients of every equation stored at the row and column locations corresponding to the various element indices. The integration of the equations over each element is referred to as local assembly while the construction of the overall system of equations from these contributions is referred to as global assembly. Thus while the discretization of the equations is derived in terms of neighbor elements, the assembly of the equations in the global matrix accounts for the actual indices of the elements. This procedure will be detailed in later chapters, however the enabling ingredients of this procedure are briefly introduced next at their most elementary level, which is in the form of topological information about elements, faces, and vertices that are represented in terms of connectivity lists.

Element connectivity relates the local assembly matrix to the global matrix so that the equations formed for one element are consistent with the equations formed for the other elements in the computational domain. Generally element to element, element to face, and element to vertex connectivities are setup. These relate the element to the neighboring elements, bounding faces, and defining vertices, respectively. Considering Fig. 4.4, the connectivity for element 9 is shown in Fig. 4.5.

Fig. 4.5

Element connectivity

Generally for arbitrary elements it is more efficient to assemble flux terms by looping over faces. In this case it is essential that information about the face element neighbors be readily available; this is defined in the Face connectivity. For faces, information about elements sharing the face is stored for use during computations. The orientation of the face is such that the normal vector to the face points from one element denoted by element 1 or owner to the second element denoted by element 2 or neighbor. Boundary faces bound only one element, defined as element 1, thus the normal vector of boundary faces is always oriented outside of the domain. The connectivity for Face 12 is shown in Fig. 4.6.

Fig. 4.6

Face connectivity

Vertex connectivity is useful for post processing and for gradient computation. As shown in Fig. 4.7, generally it involves the lists of elements and faces that share the vertex.

Fig. 4.7

Vertex connectivity

The mapping between local and global indices is briefly illustrated in Fig. 4.8 for a mesh of five elements.

Fig. 4.8

Local element matrix assembly into global matrix

Example 1

For the mesh shown below, derive the element connectivity and represent it in a global matrix (Fig. 4.9)

Fig. 4.9

Mesh for example 1

Solution

In this mesh element counting starts from 1. The connectivity for the various elements are given by

this can be represented in a global matrix as

4.1.4 Step III: Equation Discretization

In step III, the governing partial differential equations, are transformed into a set of algebraic equations, one for each element in the computational domain. These algebraic equations are then assembled into a global matrix and vectors that can be expressed in the form

(4.2)

where the unknown variable T is defined at each interior element and at the boundary of the computational domain. Boundary values for T are generally obtained from the specified boundary conditions. To this end an element field has to be defined for T, and generally for each governing equation.

As schematically depicted in Fig. 4.10, the element field consists of an array of values defined at the centroid of each element, designated by the interior element field, which is represented by one array of size equal to the total number of interior and boundary elements.

Fig. 4.10

Element field

The equation discretization step is performed over each element of the computational domain to yield an algebraic relation that connects the value of a variable in an element to the values of the variable in the neighboring elements. This algebraic equation is derived by discretizing the differential equation, which for the example considered is the energy equation written in terms of temperature T, (i.e., T is the unknown variable). As shown below, in the finite volume method the discretization of the equation is performed by first integrating the differential equation over a control volume or cell to obtain a semi discretized form of the equation and then approximating the variation of the dependent variable between grid elements through imposed profiles to obtain the final discretized form. The fact that only a few grid elements participate in a given discretization equation is a consequence of the piecewise nature of the chosen profiles. The value of T at a grid point thereby influences the distribution of T only in its immediate neighborhood. As the number of grid elements increases, the solution of the discretized equations is expected to approach the exact solution of the corresponding differential equation. This follows from the consideration that, as the grid elements get closer together, changes in T between neighboring grid elements become small, and then the actual details of the profile assumption become unimportant.

For a given differential equation, the possible discretization equations are by no means unique, although all types of discretization techniques in the limit of a very large number of grid elements are expected to give the same solution. The different types arise from the differences in the profile assumptions and the methods of derivation.

As an example of the equation discretization step using the finite volume method, the discretized form of the energy equation over the control volume C shown in Fig. (4.11) is sought. The process starts by integrating Eq. (4.1) over element C that enables recovering its integral balance form, which was described in Chap. 3, as

(4.3)

Then, using the divergence theorem, the volume integral is transformed into a surface integral yielding

(4.4)

This equation is actually a heat balance over element C. It is basically the integral form of the original partial differential equation and involves no approximation. Replacing the surface integral by a summation over the control volume faces, Eq. (4.4) becomes

(4.5)

where f represents the integration point at the centroid of the bounding face. This transformation is the first approximation introduced. Therefore the integral in Eq. (4.4) is numerically approximated by the fluxes at the centroids of the faces. This is a second order approximation as will be demonstrated in a later chapter.

Fig. 4.11

Discretization stencil

Expanding the summation, Eq. (4.5) can be written as

(4.6)

Considering face f ₁ shown in Fig. (4.12), the surface vector and temperature gradient in Eq. (4.6) are given by

(4.7)

where

x C

is the x-coordinate of the centroid of element C.

is the x-coordinate of the centroid of element F ₁.

is the area of face f ₁.

is the surface vector of face f ₁ directed out of element C.

is the gradient of T at the centroid of face f ₁.

Fig. 4.12

Finite volume notation

and by substitution, the first term in Eq. (4.6) is converted to

(4.8)

To proceed further, a profile approximating the variation of T between C and F 1 is needed. Assuming linear variation of T, the x-component of the gradient at the face f ₁ can be written as

(4.9)

thus Eq. (4.8) can be approximated as

(4.10)

or more generally as

(4.11)

where

(4.12)

Repeating for each of the remaining faces, the following coefficients are obtained:

(4.13)

which when substituted into Eq. (4.6) yields

(4.14)

or more compactly

(4.15)

where

(4.16)

Equations similar to Eq. (4.15) may be derived for all cells in the domain, yielding a set of algebraic equations, which can be solved using a variety of direct or iterative methods. Focusing on element C in Fig. (4.13), Eq. (4.15) implies a relation between T C and the temperatures at its four neighbors namely $$ T_{{F_{1} }} $$, $$ T_{{F_{2} }} $$, $$ T_{{F_{3} }} $$, and $$ T_{{F_{4} }} $$, which in global assembly would be $$ T_{9} $$, and $$ T_{10} $$, $$ T_{4} $$, $$ T_{8} $$ and $$ T_{15} $$ .

Fig. 4.13

Element notation

Similar equations are also derived for boundary elements and their collection yields the set of equations illustrated in Fig. (4.14), which can be represented in matrix form as given in Eq. (4.2), where A is the matrix of coefficients, [T] the solution vector, and b is a vector composed of terms that cannot be included in A. The methodology to solve Eq. (4.2) is presented in the next section.

Fig. 4.14

System of equations

Finally it should be stated that the properties of the finite volume method as related to accuracy, robustness, and other characteristics will be reviewed in later chapters. This includes examining in more details the finite volume discretization of the diffusion term, which was presented above for a rectangular Cartesian grid.

4.1.5 Step IV: Solution of the Discretized Equations

The discretization of the differential equation results in a set of discrete algebraic equations, which must be solved to obtain the discrete values of T. The coefficients of these equations may be independent of T (i.e., linear) or dependent on T (i.e. non-linear). The techniques to solve this algebraic system of equations are independent of the discretization method, and represent the various trajectories that can be followed to obtain a solution. For the linear algebraic sets encountered in this book, the uniqueness of the solution is guaranteed. Therefore if the adopted solution method gives a solution, it will be the desired solution. All solution methods (i.e., all paths to solution) which arrive at a solution will give the same solution for the same set of discrete equations.

The solution methods for solving systems of algebraic equations may be broadly classified as direct or iterative and are briefly reviewed below.

4.1.5.1 Direct Methods

In a direct method the solution to the system of equations [e.g., Eq. (4.2)] is obtained by applying a relatively complex algorithm, in comparison with an iterative method, only once to obtain the solution for a given set of coefficients. An example of a direct method is matrix inversion whereby the solution is obtained as

(4.17)

Therefore a solution for [T] is guaranteed if A ⁻¹ can be found. However, the operation count for the inversion of an N × N matrix is O(N ³), which is computationally expensive. Consequently, inversion is almost never employed in practical problems. More efficient methods for linear systems are available. For the discretization methods of interest here, A is sparse, and for structured meshes it is banded. For certain types of equations (e.g., pure diffusion), the matrix is symmetric. Matrix manipulation can take into account the special structure of A in devising efficient solution techniques. Such methods will be reviewed in Chap. 10.

In general, direct methods are rarely used in computational fluid dynamics because of their large computational and storage requirements. Most industrial CFD problems today involve hundreds of thousands of cells, with 5–10 unknowns per cell even for simple problems. Thus the matrix A is usually very large, and most direct methods become impractical for these large problems. Furthermore, the matrix A is usually non-linear, so that the direct method must be embedded within an iterative loop to update nonlinearities in A. Thus, the direct method is applied over and over again, making it all the more time-consuming.

4.1.5.2 Iterative Methods

Iterative methods follow a guess-and-correct procedure to gradually refine the estimated solution by repeatedly solving the discrete system of equations. Let us consider an extremely simple Gauss-Seidel iterative method. The overall solution loop for this method may be written as follows:

(a)

Guess the discrete values of T at all grid elements in the domain.

(b)

Visit each grid element in turn. Update T using

(4.18)

The neighboring values are required for the update of T C . These are assumed known at prevailing values. Thus, grid elements which have already been visited will have updated values of T and those that have not will have old values.

(c)

Sweep the domain until all grid elements are covered. This completes one iteration.

(d)

Check if an appropriate convergence criterion is met. The requirement, for example, could be that the maximum change in the grid-point values of T be less than 1 %. If the criterion is met, stop. Else, go back to step b and repeat.

The iteration procedure described here is not guaranteed to converge to a solution for arbitrary combinations of a C and a NB . Convergence of the process is guaranteed for linear problems if the Scarborough criterion is satisfied. The Scarborough criterion requires that a C and a NB should satisfy

(4.19)

Matrices which satisfy the Scarborough criterion have diagonal dominance.

The Gauss-Seidel scheme can be implemented with very little storage. All that is required is storage for the discrete values of T at the grid elements. The coefficients can be computed on the fly if desired, since the entire coefficient matrix for the domain is not required when updating the value of T at any grid point. Also, the iterative nature of the scheme makes it particularly suitable for non-linear problems. If the coefficients depend on T, they may be updated using prevailing values of T as iterations proceed. Nevertheless, the Gauss-Seidel scheme is rarely used in practice for solving the systems encountered in CFD. The rate of convergence of the scheme decreases to unacceptably low levels if the system of equations is large. In Chap. 10, an algebraic multigrid method will be used to accelerate the rate of convergence of iterative schemes and improve their performance.

4.1.6 Other Types of Fields

In addition to the element field introduced above, other fields are defined for different purposes. Two such fields include the face field and the vertex field that are briefly described below.

The face field consists of the array of values defined at the centre of the faces. As shown in Fig. 4.15, it defines a number of arrays for the interior faces and the various patch faces. The face field is used, for example, to define the face mass fluxes for use when solving advective and flow problems.

Fig. 4.15

Face field

The vertex field schematically depicted in Fig. 4.16 stores variables at the vertices; these again are grouped into interior vertices and patch vertices. Vertex fields are usually used for post processing, and in some cases for gradient computation.

Fig. 4.16

Vertex field

4.2 Closure

This chapter overviewed the discretization process, underlining on the way the basic ingredients needed for the development of a CFD code. The coming chapters will take each of these ingredients and dissect it, while developing the “uFVM” and learning about the industrial open source CFD library, denoted by OpenFOAM®. The next two chapters will further expand on the idea of finite volume mesh and finite volume discretization.

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_5

5. The Finite Volume Method

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

Similar to other numerical methods developed for the simulation of fluid flow, the finite volume method transforms the set of partial differential equations into a system of linear algebraic equations. Nevertheless, the discretization procedure used in the finite volume method is distinctive and involves two basic steps. In the first step, the partial differential equations are integrated and transformed into balance equations over an element. This involves changing the surface and volume integrals into discrete algebraic relations over elements and their surfaces using an integration quadrature of a specified order of accuracy. The result is a set of semi-discretized equations. In the second step, interpolation profiles are chosen to approximate the variation of the variables within the element and relate the surface values of the variables to their cell values and thus transform the algebraic relations into algebraic equations. The current chapter details the first discretization step and presents a broad review of numerical issues pertaining to the finite volume method. This provides a solid foundation on which to expand in the coming chapters where the focus will be on the discretization of the various parts of the general conservation equation. In both steps, the selected approximations affect the accuracy and robustness of the resulting numerics. It is therefore important to define some guiding principles for informing the selection process.

5.1 Introduction

The popularity of the Finite Volume Method (FVM) [1–3] in Computational Fluid Dynamics (CFD) stems from the high flexibility it offers as a discretization method. Though it was preceded for many years by the finite difference [4, 5] and finite element methods [6], the FVM assumed a particularly prominent role in the simulation of fluid flow problems and related transport phenomena as a result of the work done by the CFD group at Imperial College in the early 70 s under the direction of Professor Spalding [7], with such contributors as Patankar [8], Gosman [9], and Runchal [10, 11] to cite a few. The FVM owes much of its flexibility and popularity to the fact that discretization is carried out directly in the physical space with no need for any transformation between the physical and the computational coordinate system. Furthermore its adoption of a collocated arrangement [12] made it suitable for solving flows in complex geometries. These developments have expanded the applicability of the FVM to encompass a wide range of applications while retaining the simplicity of its mathematical formulation. Another important aspect of the FVM is that its numerics mirrors the physics and the conservation principles it models, such as the integral property of the governing equations, and the characteristics of the terms it discretizes. In what follows the semi-discretized form of a general scalar equation is derived. Then the properties required from the discretization method are discussed along with some guiding principles. The chapter ends with a discussion of a number of issues pertinent to the FVM. The transformation of the semi-discretized equation into algebraic equations will be the subject of a number of chapters to follow.

5.2 The Semi-Discretized Equation

In step 1 of the finite volume discretization process, the governing equations are integrated over the elements (or finite volumes) into which the domain has been subdivided, then the Gauss theorem is applied to transform the volume integrals of the convection and diffusion terms into surface integrals. Following this step, the surface and volume integrals are transformed into discrete ones and integrated numerically through the use of integration points (ip). To clarify this approach and to develop an adequate appreciation for the subtleties of the advanced discretization schemes discussed in later sections, the following example illustrates the application of the technique for a two-dimensional transport problem.

As presented in Chap. 3, the conservation equation for a general scalar variable $$ \phi $$ can be expressed as

(5.1)

The steady-state form of the above equation is obtained by dropping the transient term and is given by

(5.2)

By integrating the above equation over the element C shown in Fig. 5.1; Eq. (5.2) is transformed to

(5.3)

Replacing the volume integrals of the convection and diffusion terms by surface integrals through the use of the divergence theorem, the above equation becomes

(5.4)

where bold letters indicate vectors, (·) is the dot product operator, $$ Q^{\phi } $$ represents the source term, S the surface vector, v the velocity vector, $$ \phi $$ the conserved quantity, and $$ \mathop {\oint }\limits_{{\partial V_{C} }} $$ the surface integral over the volume V C .

Fig. 5.1

Conservation in a discrete element

5.2.1 Flux Integration Over Element Faces

Denoting the convection and diffusion flux terms by $$ {\mathbf{J}}^{\phi ,C} $$ and $$ {\mathbf{J}}^{\phi ,D} $$, respectively, their expressions are given by

(5.5)

(5.6)

Further, defining the total flux $$ {\mathbf{J}}^{\phi } $$ as the sum of the convection and diffusion fluxes, it can be written as

(5.7)

Replacing the surface integral over cell C by a summation of the flux terms over the faces of element C, the surface integrals of the convection, diffusion, and total fluxes become

(5.8)

(5.9)

(5.10)

In Eqs. (5.8)–(5.10) the surface fluxes are evaluated at the faces of the element rather than integrated within it. This transformation has important consequences on the properties of the FVM, one of which is that it renders the method conservative, as will be discussed later.

To proceed further with the discretization, the surface integral at each face of the element in addition to the volume integral of the source term have to be evaluated. Using a Gaussian quadrature the integral at the face f of the element becomes

(5.11)

where ip refers to an integration point and ip(f) the number of integration points along surface f. As seen in Fig. 5.2, a number of options are available with their accuracy depending on the number of integration points used and the weighing function ω ip . For a simple mean value integration (Fig. 5.2a), also known as the trapezoidal rule, only one integration point located at the centroid of the face is used with a weighing function of value equal to 1 (i.e., ip = ω ip  = 1). This approximation is second order accurate and is applicable in two and three dimensions. Another option (Fig. 5.2b) in two dimensions, which is third order accurate, involves two integration points (ip = 2) positioned at $$ \xi_{1} = (3 - \sqrt 3 )/6 $$ and $$ \xi_{2} = (3 + \sqrt 3 )/6 $$ where ξ is distance along the face measured from one end and normalized by the total length, with weights $$ \omega_{ 1} = \omega_{ 2} = 1/ 2 $$. A third option depicted in Fig. 5.2c uses three integration points (ip = 3) positioned at $$ \xi_{1} = (5 - \sqrt {15} )/10,\xi_{2} = 1/2 $$, and $$ \xi_{3} = (5 + \sqrt 15 )/10 $$, with weights ω ₁ = 5/18, ω ₂ = 4/9, and ω ₃ = 5/18. It is clear that the computational cost rises with the number of integration points used in the approximation. With ip(f) denoting the number of integration points along face f, the general discretized relations for the convection and diffusion terms become

(5.12)

(5.13)

Fig. 5.2

Surface integration of fluxes using a one integration point, b two integration points, and c three integration points

5.2.2 Source Term Volume Integration

Volume integration is used for the source term. Adopting a Gaussian quadrature integration, the volume integral of the source term is computed as

(5.14)

As with surface flux integration, Fig. 5.3 shows different options for volume integration with their accuracy depending on the number of integration points used (ip) and the weighing function ω ip .

Fig. 5.3

Volume integration of source terms using a one integration point, b four integration points, and c nine integration points

For one point Gauss integration (Fig. 5.3a), ip = ω ip  = 1 with the integration point located at the centroid of the element. This approximation is second order accurate and is applicable in two and three dimensions. In two dimensions, four point gauss integration (Fig. 5.3b) involves the use of four integration points. The weights are computed as the product of the one dimensional weights and the integration points (ξ, η) are obtained from the one dimensional profiles. Therefore the function is calculated at $$ \left[ {\left( {3 - \sqrt 3 } \right)/6,\left( {3 + \sqrt 3 } \right)/6} \right] $$, $$ \left[ {\left( {3 + \sqrt 3 } \right)/6,\left( {3 + \sqrt 3 } \right)/6} \right] $$, $$ \left[ {\left( {3 - \sqrt 3 } \right)/6,\left( {3 - \sqrt 3 } \right)/6} \right] $$, and $$ \left[ {\left( {3 + \sqrt 3 } \right)/6,\left( {3 - \sqrt 3 } \right)/6} \right] $$ with the weights being equal (ω ip  = 1/4 for ip = 1 to 4). The nine point gauss integration method (Fig. 5.3c) involves the use of nine integration points. The accuracy increases with increasing the number of integration points but so does the computational cost.

5.2.3 The Discrete Conservation Equation for One Integration Point

While the above terms can be discretized with any specified number of integration points, it is customary for the finite volume method to use one integration point, yielding second order accuracy. This was found to be a good compromise between accuracy and flexibility while keeping the method simple and relatively of low computational cost. Following the mid-point integration approximation, the semi-discrete steady state finite volume equation for element C shown in Fig. 5.4 can be finally simplified to

Fig. 5.4

Fluxes at element surfaces

(5.15)

The aim of the second stage of the discretization process is to transform Eq. (5.15) into an algebraic equation by expressing the face and volume fluxes in terms of the values of the variable at the neighboring cell centers. This linearization of the fluxes is at the core of the second discretization step.

5.2.4 Flux Linearization

As schematically depicted in Fig. 5.2a, the face flux can be split into a linear part, function of the $$ \phi $$ values at the nodes straddling the face (i.e., $$ \phi_{C} $$ and $$ \phi_{F} $$), and a non-linear part, which includes the remaining portion that cannot be expressed in terms of $$ \phi_{C} $$ and $$ \phi_{F} $$. The resulting equation can be written as

(5.16)

where FluxT f represents the total flux through face f, and is decomposed into three terms. The first two terms represent the contributions of the two elements sharing the face and are written via the linearization coefficients FluxC f and FluxF f . The last term describes the nonlinear contribution that cannot be expressed in terms of $$ \phi_{C} $$ and $$ \phi_{F} $$ and is given by the non-linear term FluxV f . The values of FluxC f , FluxF f , and FluxV f obviously depend on the discretized term and the scheme used for its discretization.

The flux linearization is thus obtained by substituting Eq (5.16) into the left hand side of Eq. (5.15). Repeating for all cell faces yields

(5.17)

The linearization of the volume flux is performed, as shown in Fig. 5.3a, by expressing it as a linear function of the element node value $$ \phi_{C} $$ and is given by

(5.18)

In the case of a constant source term, the volume flux, which represents the right hand side of Eq. (5.15), reduces to

(5.19)

Substitution of Eqs. (5.17) and (5.18) in Eq. (5.15), yields the sought after algebraic relation as

(5.20)

where the relations between equation coefficients and flux linearization coefficients are expressed as

(5.21)

Example 1

Find the linearization coefficients for the discretization of the convection term when the velocity field is in the positive direction using the approximation $$ \phi _{f} = \phi_{C} $$ (this is known as the upwind scheme).

Solution

thus

With $$ \phi_{f} = \phi_{C} $$, the coefficients in the total flux equation are obtained as

and the total flux is expressed as

5.3 Boundary Conditions

The evaluation of the fluxes at the faces of a domain boundary does not require, in general, a profile assumption. Rather a direct substitution is usually performed. The type of boundary conditions are numerous. However, two of the most widely used ones for general scalars are the Dirichlet and the Neumann boundary conditions. In mathematical terms these are respectively a value specified (or a first type) and a flux specified (or a second type) boundary condition.

5.3.1 Value Specified (Dirichlet Boundary Condition)

Consider the case where some scalar $$ \phi $$ is being convected through an inlet. Assuming the diffusion of $$ \phi $$ to be negligible, the boundary condition can be expressed as

(5.22)

For the boundary face shown in Fig. 5.5, the boundary flux is evaluated using the known value of $$ \phi_{b} $$ given by Eq. (5.22). Therefore the value of the boundary flux is not unknown, rather it can be directly evaluated as

(5.23)

Fig. 5.5

Dirichlet boundary condition

Thus

(5.24)

5.3.2 Flux Specified (Neumann Boundary Condition)

Considering the case shown in Fig. 5.6 where the boundary face of the element C represents physically a wall where a flux for the quantity $$ \phi $$ is specified. Mathematically this is equivalent to writing

(5.25)

Fig. 5.6

Neumann boundary condition

In the above equation q b,specified is a known quantity specified by the user, representing the flux per unit area.

Thus

(5.26)

The treatment of these two boundary conditions and others will be detailed in the following chapters along with the treatment of the terms related to step two discretization.

5.4 Order of Accuracy

As discussed earlier, fluxes at the faces and sources over the element are evaluated following the mean value approach, i.e., using the value at the centroid of the surface (midpoint rule) and cell, respectively. This treatment, in addition to the assumed variation of $$ \phi $$ in space around point C, i.e., $$ \phi = \phi \left( {\mathbf{x}} \right) $$, determine the accuracy of the discretization procedure. In the adopted method, $$ \phi $$ is assumed to vary linearly in space, i.e.,

(5.27)

5.4.1 Spatial Variation Approximation

The spatial variation of the variable $$ \phi = \phi \left( {\mathbf{x}} \right) $$ within the element shown in Fig. 5.7 can be described via a Taylor series expansion around point x C as

(5.28)

Fig. 5.7

Variation within an element

The expression (x − x C ) n in the equation and consequent ones represents the nth tensorial product of the vector (x − x C ) with itself, producing an nth rank tensor. The operator (:) is the inner product of two 2nd rank tensors, (::) is the inner product of two 3rd rank tensors, and more generally “$$ \underbrace {:: \ldots ::}_{{\left( {n - 1} \right)times}} $$” is the inner product of two nth rank tensors, all yielding a scalar.

Comparison between the assumed variation given by Eq. (5.27) and the Taylor series expansion [Eq. (5.28)] indicates an error proportional to |(x − x C )²| and implying a second order spatial accuracy.

5.4.2 Mean Value Approximation

The accuracy of the mean value approximation can be derived by integrating the variable $$ \phi \left( {\mathbf{x}} \right) $$ over the cell of centroid C depicted in Fig. 5.8 and leading to

(5.29)

where V C is the volume of the element. The second term is equal to zero because point C is the centroid of the element. Neglecting the last term in the equation introduces an error of order 2, demonstrating that the mean value approximation is second order accurate.

Fig. 5.8

Mean-value theorem

The convective flux at face f of element C shown in Fig. 5.9 is computed as

(5.30)

where again the second term is equal to zero as x f is the centroid of the respective element surface. Here subscript f denotes the value of the variable, in this case $$ \phi $$, at the face centroid and S is the outward pointing face surface vector.

Fig. 5.9

Convection and diffusion fluxes at element faces

For the diffusive flux, truncating second order terms and higher, the following can be written:

(5.31)

Hence for a second order method, the surface integral and the variation of $$ \phi $$ within the element should be second order accurate.

Higher order accuracy can be achieved by increasing the order of accuracy of the surface integral or of the assumed profile for $$ \phi $$. One method developed by Lilek and Peric [13] in two dimensions used a fourth order accurate surface integral, evaluated via Simpson’s rule as

(5.32)

As shown in Fig. 5.10, for face f the value of $$ \phi $$ is needed at three integration points, i.e., the surface centroid ip ₂, and the vertices of the face ip ₁ and ip ₃.

Fig. 5.10

A element face f showing the integration points where values are needed for a higher order approximation of the surface integral

To obtain a formally fourth order accurate discretization, the assumed profile of $$ \phi $$ within the element should also be fourth order accurate such that

(5.33)

In this case the accuracy of the gradient calculation has to be second order or higher and that of the Hermitian first order or higher.

5.5 Transient Semi-Discretized Equation

For unsteady state the temporal term in Eq. (5.1) is retained and in addition to integrating over the volume of the element, integration over time is also needed. In this case the integrated equation becomes

(5.34)

Further simplification of this equation requires a choice with regard to the time integration accuracy required. This will be dealt with in Chap. 13. For fixed grids, where the volume and surface of each element are constant in time, the first term can be integrated as

(5.35)

where

(5.36)

Substituting back, Eq. (5.34) reduces to

(5.37)

and using the midpoint rule, Eq. (5.37) becomes

(5.38)

Going forward beyond this point requires some assumptions as to how the variable is changing in time.

5.6 Properties of the Discretized Equations

As the size of the element tends to zero, the numerical solution is expected to be the exact solution of the general conservation equation [e.g., Eq. (5.2)] irrespective of the interpolation profile used to evaluate the element $$ \phi $$ values. However, since finite volumes are used, it is crucial for the discretized equations to possess some properties in order to ensure a meaningful solution field. These properties are discussed next.

5.6.1 Conservation

From a physical point of view it is very important for the transported variables, which are generally conservative quantities (e.g., mass, energy, etc.), to be conserved in the discretized solution domain too, otherwise results may be unrealistic. This property is inherent to the FVM because the fluxes integrated at an element face are based on the values of the elements sharing the face [8]. Thus for any surface common to two elements, the flux leaving the face of one element will be exactly equal to the flux entering the other element through that same face. Thus these fluxes are of equal magnitudes but of opposite signs (Fig. 5.11). Any method that possesses this property is said to be conservative.

Fig. 5.11

Fluxes on neighboring elements

5.6.2 Accuracy

Accuracy refers to how close a numerical solution is to the exact solution. However, in most of the cases the exact solution for the problem to be solved is unknown. Therefore a direct comparison to check accuracy is not possible. An alternative is to consider the truncation error as a measure of accuracy. The error associated with the first step discretization of the various terms presented above was O|(x − x f )|², which represents a second order accuracy. This means that if the number of grid points is doubled then the discretization error will be reduced by a factor of 4. The truncation error of a discretization scheme is the largest truncation error of each of the individual terms in the discretized equation. The discretization error does not give the value of the error on a certain grid. It does tell, however, how fast the error will decrease with grid refinement. The higher the order of the error the faster it will decrease with mesh refinement.

5.6.3 Convergence

The nonlinear nature of the conservation equations dealt with here necessitates an iterative approach. Starting with an initial guess, solutions are obtained by repeatedly applying a solution algorithm with the solution at the end of an iteration used as an initial guess for the following iteration. Ideally a solution is said to be converged when it does not change any further as iterations progress. In practice, however, a solution is established converged when changes between two consecutive iterations fall below a vanishing quantity ε. In general convergence is used to indicate the obtainment of a solution with any method. Sometimes the term “convergence” is used to indicate the attainment of a grid independent solution, i.e., a solution that does not change with any further grid refinement.

5.6.4 Consistency

A solution to an algebraic equation approximating a given partial differential equation is said to be consistent if, at each point in the solution domain, the numerical solution approaches the exact solution of the partial differential equation as the time step and grid spacing tend to zero, i.e., as the discretization error approaches zero. For this to be true, the discretization error should be some power of Δt and/or Δx. If the discretization error is expressed in terms of Δx/Δt then, for consistency, Δx should tend to zero at a faster rate than Δt.

5.6.5 Stability

Stability refers to the behavior of the discretized equations to be resolved by an iterative solver. It indicates whether the resulting system of algebraic equations can be solved under a variety of initial and boundary conditions. In this sense stability is not really a property of the discretization process but rather a property of the resulting system of equations. As mentioned in a previous chapter, a sufficient condition for a system of linear equations to be stable and converge to a solution is for it to satisfy the Scarborough criterion, i.e., for its matrix of coefficients to be diagonally dominant.

For transient problems, a stable numerical scheme keeps the error in the solution bounded as time marching proceeds. The use of explicit or implicit transient schemes has direct impact on the stability of the numerical method. The stability of explicit methods is ensured by limiting the size of the time step. On the other hand, the stability of implicit methods can be enhanced by under-relaxing the discretized set of algebraic equations either through the use of under relaxation factors or by applying the false-transient approach, as described in a later chapter.

5.6.6 Economy

Economy is an important consideration in the development and application of CFD codes. It is understood to mean that the time required to compute realistic flow problems should not be prohibitive.

5.6.7 Transportiveness

The directional properties exhibited by fluid transport are well known and are signaled by the change in the type of the transport scalar equation [Eq. (5.2)], which may become hyperbolic under certain conditions. The implications on the finite volume equation, visualized in Fig. 5.12, can be explained as follows. If there is a constant source of $$ \phi $$ within an element C in a flow field with uniform velocity and diffusivity, then the shapes of the contours of constant scalar $$ \phi $$ will be influenced by the ratio of convection to diffusion strengths, i.e., the Péclet number (Pe) defined as

(5.39)

Fig. 5.12

Illustration of the transportive property of fluid flow

Based on Eq. (5.39), the case Pe = 0 indicates that the transport of $$ \phi $$ is governed by diffusion, which has an elliptic behavior [8]. In this case, isolines of $$ \phi $$ are circular and the value of $$ \phi $$ at C is influenced by the surrounding nodes W and E (Fig. 5.12). Increasing convection effects (i.e., increasing Pe), the circular contours become elliptic in shape and the region influencing the value of $$ \phi $$ at C shifts in the direction of the flow. Therefore for high Pe flows, events at node C will have a weak or no influence on upstream nodes, while downstream nodes will be strongly affected.

Failure to observe this requirement in the selected discretization schemes can give rise to unstable solutions (i..e., unphysical oscillations).

5.6.8 Boundedness of the Interpolation Profile

Ensuring conservation does not guarantee that other important properties of the original partial differential equation will be maintained by the discretized equation. For example physical considerations lead to the conclusion that in the absence of sources, the value of the conserved variable $$ \phi $$ within the domain should be bounded by the values at the domain boundaries [14]. The discretized equation

(5.40)

would fulfill this requirement when the nodal $$ \phi_{C} $$ values satisfy the following constraint:

(5.41)

where F i represents the ith neighbor of C and N their number. This can be achieved by a judicial control of the discretization schemes and their linearization, as will be detailed in later chapters.

5.7 Variable Arrangement

While the cell-centered variable arrangement is the one selected in OpenFOAM® and generally preferred with the FVM (Fig. 5.13a), vertex-centered [15] (Fig. 5.13b) variable arrangement methods have also been used. Two vertex-centered arrangements have been adopted resulting in either overlapping elements or a dual mesh, respectively. Because the dual mesh method is more popular, it is described next as a representative of vertex-centered methods.

Fig. 5.13

a Cell-centered arrangement; b vertex-centered arrangement

5.7.1 Vertex-Centered FVM

In a vertex-centered arrangement the flow variables are stored at the vertices (or grid points), with elements constructed around the variable locations by using the concept of a dual mesh and dual cells [16] (Fig. 5.14). Adopting this concept, a cell can be created around a grid point in several ways. In two dimensions, one approach (Fig. 5.14a) is by connecting the centroids of the cells having the grid point in common. As displayed in Fig. 5.14b a second possibility is to join the centroids of the surrounding elements to the centroids of their faces. The same construction procedure can be used in three dimensional situations where an element around a grid point is created by properly connecting surrounding cells’ centroids, faces’ centroids, and edges’ centroids resulting in non-overlapping elements.

Fig. 5.14

Vertex-centered arrangement: a dual cells connecting centroids of cells, and b dual cells connecting centroids of cells to centroids of faces

The use of a vertex-centered arrangement of variables allows for an explicit profile to be defined over the elements in terms of the vertex variables. In this case the variables represent point values and variation through the element can be computed using shape functions or interpolation profiles. This approach permits an accurate resolution of face fluxes for all mesh topologies, but yields a lower order accuracy of element-based integrations since the vertex is not necessarily at the element centroid. Moreover, it increases the storage requirements due to the creation of larger matrix. Furthermore handling of boundary conditions in cell-vertex schemes, as shown in Fig. 5.14b, requires additional treatment in order to ensure a consistent solution at boundary points shared by multiple grid blocks. Still a major disadvantage is the need to base the mesh on a set of element types for which a shape function can be defined.

Another shortcoming of the vertex-centered scheme with dual elements appears at solid boundaries where only a portion of an element is formed and the node where values are stored is at the wall (Fig. 5.14b). In a regular cell, the integration of face fluxes results in a residual located at the main point inside the element where values are stored. In this case however, the residuals will be stored at the wall boundary creating a discrepancy and causing an increase in the discretization error there in comparison with cell-centered schemes. Additional complications may also arise at sharp edges and branch cuts.

5.7.2 Cell-Centered FVM

The cell-centered variable arrangement is currently the most popular type of variable arrangement used with the FVM. With this practice, the variables and their related quantities are stored at the centroids of grid cells or elements. Thus, the elements are identical to the discretization elements and, in general, the method is second order accurate since all quantities are computed at element and face centroids, where the difference between the value of the variable and its average is O(Δx ²). Variations within the cell can be re-constructed using a Taylor series expansion. Another advantage of the cell-centered formulation is that it allows for the use of general polygonal elements with no need for pre-defined shape functions. This permits a straightforward implementation of a full multigrid strategy.

However two important disadvantages of the method are its treatment of non-conjunctional elements and the manner the diffusion term is discretized on non-orthogonal cells. The first issue influences the accuracy of the method, the second its robustness, while both being affected by the quality of the mesh.

Consider the two-cell arrangement shown in Fig. 5.15. It is clear that any average of a value defined at C and F will be defined at $$ f^{\prime} $$ rather than f, the centroid of the face. Thus any discretization procedure using this interpolated value will not have an O(Δx ²) accuracy.

Fig. 5.15

Two non-junctional cell-centered elements

For a cell-centered scheme the discretization error depends strongly on the smoothness of the grid. Results for such a situation are displayed in Fig. 5.16. The physical situation displayed in Fig. 5.16a represents an annulus between two horizontal cylinders of rhombic cross-sections. The inner cylinder is maintained at the uniform hot temperature T h while the outer cylinder is kept at the cold temperature T c . The difference in temperature creates density variation within the enclosure and gives rise to buoyancy forces that establish a flow field. Using the grid system displayed in Fig. 5.16a, the velocity and temperature distributions within the enclosure are obtained numerically using a finite volume method. Generated isotherms are displayed in Fig. 5.16b. By carefully inspecting Fig. 5.16b small kinks can be seen in the region around the horizontal centerline of the domain. The region around the kinks is magnified and the grid and isotherms in that region are displayed in Fig. 5.16c, d, respectively. The kinks in the isotherms are clear in the magnified plot and are due to the use of the grid with slope discontinuity causing a discretization error that cannot be reduced independent of how much the grid is refined. This zero order error does not arise with a cell-vertex scheme. Despite this fact, for a sufficiently smooth grid, the cell-centered arrangement can attain accuracy of order two or higher.

Fig. 5.16

a Grid used in solving for natural convection in the annulus between horizontal cylinders of rhombic cross sections; b isotherms over the domain; c a magnified region showing the grid around the horizontal centerline of the domain; d a magnified region around the horizontal centerline showing the kinks in the generated isotherms

The other issue that affects cell centered FVM is the treatment of non-orthogonality in the discretization of the diffusion term. This will be covered in detail in Chap. 8, however a brief explanation is useful at this stage.

In the discretization of the diffusion term (Fig. 15.17) the value of the angle θ extending between the unit vector e (which is in the direction of the line joining the centroids of the elements C and F ) and the unit vector n (which is normal to the face shared by the elements C and F) affects the degree of implicitness and hence the robustness of the method applied in the discretization of the diffusion term.

Fig. 15.17

A non-orthogonal element

For discretization, the diffusion term is generally written as

(5.42)

The larger the angle θ is, the larger the explicit term will be, and the less robust the discretization method becomes.

To summarize, the vertex-centered scheme with dual elements and the cell-centered scheme are numerically very similar in the interior of a domain for steady state calculations. The only situation where the performance of the vertex-centered scheme is superior to that of the cell-centered scheme is over a distorted grid. In all other situations, it is more advantageous to use the cell-centered arrangement as it leads to a more straightforward implementation in a computer code.

5.8 Implicit Versus Explicit Numerical Methods

As described in Sect. 5.1, once the number of integration points and the type of linearization are defined, the cell-centered finite volume discretization method results in a set of equations with the values of the dependent variables at the cell centers as unknowns. The way these unknowns are organized and solved, classifies the adopted computational approach. Numerical solution schemes are often referred to as being either explicit or implicit.

An explicit numerical method is one in which the dependent variables are computed directly via already known values. In this case any discretization operator can be directly evaluated based on the actual variable values.

On the other hand, a numerical method is said to be implicit when the dependent variables are treated as unknowns and assembled to form a coupled set of equations which are then solved via special numerical tools using either a direct or an iterative solution algorithm.

The conservation equations dealt with in computational fluid dynamics are nonlinear and the implicit approach is most often preferred over the explicit method for solving them. Once the proper discretization and linearization are performed, the last step is to solve the set or system of algebraic equations to get the solution. Solving the corresponding system with a direct equation solver, as discussed in a previous chapter, is not feasible. The iterative approach being more economical, is the most widely, if not the only one, used. In difference with a direct approach, starting from an initial guess an iterative method progresses toward solution by using results obtained at the end of an iteration as the initial guess for the following iteration. The sequence of events is said to be converging if the intermediate computed solution is approaching the final solution, otherwise it is said to be diverging. The process is general and is used whether solving for one time step in a transient problem or for a final solution in a steady state problem. In fact adopting an iterative approach to obtain a steady state solution is computationally cheaper than marching in time until steady state is reached. Additional details about matrix iterative solvers will be covered in Chap. 10.

5.9 The Mesh Support

Now that the basis of the numerics of the FVM and its properties have been presented, it is worth outlining the needed mesh support. In all preceding derivations it has been implicitly assumed that certain geometric and topological information is readily available. Even though the description of the finite volume mesh will be the subject of the next two chapters, based on the covered material so far, it has become possible to draw a simplified list of its characteristics.

The application of the FVM as a numerical discretization technique necessitates a mesh support that provides a range of information both geometric and topological, as described next.

For an element, the needed information includes: its index, its centroid, a list of bounding faces, and a list of neighboring elements. For a face, information is needed about its index, its centroid, its surface vector, a list of neighboring elements (2 for an interior face and one for a boundary face), in addition to a list of vertices that defines it. Also needed is information about the boundaries of the computational domain, i.e., the boundary faces that define each boundary patch.

Another issue to be resolved is the orientation of the normal vector to an element face. In the above derivations it was assumed that the normal to all faces of the element were pointing outward. The normal vectors to faces in a computational domain cannot be all pointing outward. Generally any element will have some of its faces with their normal vectors pointing outward while for the remaining faces they will be pointing inward. This indicates that a proper account should be made of the face sign.

Why and how the above is defined and used will be the focus of the next chapter.

5.10 Computational Pointers

Throughout this book uFVM, a Matlab®-based finite volume CFD educational code, and openFOAM® [17], an open source finite volume code capable of solving industrial type problems, will be used to illustrate implementation details and concretize various numerical procedures. Generally, comments about implementation techniques, adopted methods, and data structure in these two codes will be added, unless otherwise stated, in the Computational Pointers’s section of every chapter to follow. Moreover, a number of uFVM test cases (testDiffusion, testAdvection, testFlow, testSource, etc.) are available for the reader and can be downloaded from the book website at the URL address mentioned earlier.

5.10.1 uFVM

The computer program uFVM is an unstructured three dimensional finite volume code that was developed for academic purposes. It is written in Matlab® and as such lends itself substantially to any type of dissection by the user. Moreover, the Matlab® environment allows users to unroll the various data structures adopted in the code at any time during the running of a case. Furthermore because it is intended for academic and teaching use, clarity of coding was high on the priority list while devising the implementation details of the various algorithms and schemes. Still all of its numerics and algorithms are similar in many ways to those used in industrial oriented CFD codes and thus uFVM is quite useful as a guide for anyone interested in developing a CFD code.

The discretized system of equations in uFVM is stored in a matrix format such that each row represents the discretized equation in one element, with the off-diagonal coefficients representing the mutual influence of neighboring elements. The computational representation of this matrix usually takes into account the fact that each row will contain only a small number of non-zero elements, specifically in each row there will be as many non-zero elements as neighbors to the element associated with the row.

For the example shown in Fig. 5.18, the mesh consists of 7 elements, and element 3 has four neighbors. Thus the discretized equation for element 3 will include 4 coefficients in addition to the diagonal coefficient. It is clear why for large meshes many of the non-diagonal elements are zero.

Fig. 5.18

Coefficients for an element equation with element connectivity

In both uFVM and as is shown later in OpenFOAM®, and indeed in all CFD codes, a sparse matrix is used to store the various coefficients of the resulting system of equations. In uFVM, the matrix A is stored in an array of arrays, where the first element of each row represents the diagonal element, while the remaining elements of the array store the non-diagonal coefficients. The right hand side of the system is stored in a separate array B. This is illustrated in Fig. 5.18.

5.10.2 OpenFOAM®

OpenFOAM® (Open source Field Operation And Manipulation) is an object-oriented C++ framework that can be used to build a variety of computational solvers for problems in continuum mechanics with a focus on finite volume discretization. OpenFOAM® also includes several ready solvers, utilities, and applications that can be directly used. At the core of these libraries are a set of object classes that allow the programmer to manipulate meshes, geometries, and discretization techniques at a high level of coding. Tables 5.1, 5.2, 5.3 and 5.4 present a list of the main OpenFOAM® classes and their functions. These classes represent the basic bricks for the development of OpenFOAM® based applications and utilities. They enable programmers constructing a variety of algorithms while allowing for extensive code re-use.

Table 5.1

Numerics and discretization

Objects

Type of data

OpenFOAM® Class

Interpolation

Differencing schemes

surfaceInterpolation<template>

Explicit discretization: differential operator

ddt, div, grad, curl

fvc::

Implicit discretization: differential operator

ddt, d2dt2, div, laplacian

fvm::

Table 5.2

Computational domain

Objects

Type of data

OpenFOAM® Class

Variables

Primitive variables

scalar, vector, tensor

Mesh components

Point, face, cell

point, face, cell

Finite volume mesh

Computational mesh

fvMesh, polyMesh

Time

Time database

Time

Table 5.3

Field operation

Objects

Type of data

OpenFOAM® Class

Field

List of values

Field<template>

Dimensions

Dimension set up

dimensionSet

Variable field

Field + mesh + boundaries + dimension

GeometricField<template>

Algebra

+, −, pow, = , sin, cos…

field operators

Table 5.4

Linear equation systems and linear solvers

Objects

Type of data

OpenFOAM® Class

Sparse matrix

Matrix coefficients and manipulation

lduMatrix, fvMatrix

Iterative solver

Iterative matrix solvers

lduMatrix::solver

Preconditioner

Matrix preconditioner

lduMatrix::preconditioner

Another characteristic of OpenFOAM® is its use of operator overloading that allows algorithms to be expressed in a natural way. For example, the discretization of the transport equation for a generic scalar $$ \phi $$ given by

(5.43)

is basically written in OpenFOAM® as (Listing 5.1)

Listing 5.1

Script for solving a simple transport equation using OpenFOAM®

The fvm::div operator for example, takes the convective flux as a coefficient field defined over the faces of the control elements and phi as the variable field defined over the cell centroids, and returns a system of equations including a LHS matrix and a RHS source that represent the discretization of the convection operator. These LHS matrices and RHS vectors are generated for each of the operators and then added or subtracted as needed to yield the final system of equations that represent the discretized set of algebraic equations defined over each element of the computational domain.

The namespaces fvm:: and fvc:: allow for the evaluation of a variety of operators implicitly and explicitly, respectively.

The explicit operator fvc, named “finite volume calculus”, returns an equivalent field based on the actual field values. For example the operator fvc::div$$ (\phi) $$ returns an equivalent geometricField in which each cell contains the value of the divergence of the variable $$ (\phi) $$.

The fvm implicit operator, instead, defines the implicit finite volume discretization in terms of matrices of coefficients. For example fvm::laplacian($$ \phi $$) returns an fvMatrix in which all the coefficients are based on the finite volume discretization of the laplacian.

The role of the fvm:: and fvc:: operators is to construct the LHS and RHS of a system of equations representing the discretized form of Eq. (5.43) over each element in the mesh. The discretization process yields a system of equations that can be represented in the matrix form shown in Fig. 5.19.

Fig. 5.19

The matrix “lduMatrix” and the vector “source” in which the coefficients and sources are stored

Each row of the system represents the discretized equation in one element, with the off-diagonal coefficients representing the mutual influence of the neighboring elements.

In OpenFOAM® the matrix of coefficients is stored in a class named lduMatrix and the specialized fvMatrix. The chosen storage format of the coefficients is based on the ldu sparse format, in which all coefficients are stored in three main arrays: diagonal, upper, and lower. The diagonal coefficients are thus stored in one array accessed by diag() function with its dimension being equal to the number of elements in the computational domain. The upper and lower coefficients are stored each in an array as shown in Fig. 5.20. The source or the right hand side is stored under a specific vector called source with its dimension being also equal to the number of cells over the computational domain.

Fig. 5.20

The ldu sparse matrix storage (lduMatrix)

It is worth noting that despite defining the fvMatrix class as a “template” the vector specialization of the class does not imply a block coupled form of the matrix itself but just a vector of scalar equations that are solved in a standard segregated approach. This is confirmed by the code defined inside the fvMatrix class shown in Listing 5.2 with its member function, which returns the diagonal vector coefficients of the matrix, only returning as object a scalar field independently of the template type.

Listing 5.2

Excerpt of the code defined inside the fvMatrix class returning as object a scalar field

More details on the coefficients’ storage techniques used in uFVM and OpenFOAM® will be presented in Chap. 7.

5.11 Closure

In this chapter a general overview of the FVM was presented. The discretization process was shown to involve two distinct steps, with step 1 resulting in a set of semi-discretized equations. The chapter also discussed some guiding principles for the discretization process, which guarantee that the resulting discretized equation will possess some desirable attributes. Before embarking onto a detailed description of the numerical techniques that will be used in step 2 of the discretization process, the focus of the next chapter will be on the discretization of the computational domain and some related issues.

5.12 Exercises

Exercise 1

A critical tool used with OpenFOAM® is Doxygen [18]. It is an open source software that generates automatic documentation from annotated C++ sources. Doxygen uses the UML (http://​www.​uml-diagrams.​org/​class-reference.​html) graph formalism and is capable of visually displaying the relations between the various classes, inheritance diagrams, and collaboration diagrams, which are all generated automatically as easily browsed HTML documents. Two options are available to access Doxygen. The first is to generate the documents by direct compilation on the local machine (the main files are placed in $WM_PROJECT_DIR/doc/Doxygen). The second option is to access Doxygen on the web at the address http://​www.​openfoam.​org/​docs/​cpp/​. This latest option yields always up to date documentation. To start, either open the browser at the address http://​www.​openfoam.​org/​docs/​cpp/​ or open the file $WM_PROJECT_DIR/doc/Doxygen/html/index.html. Once opened, click on the Classes button that appears in the menu in the upper part of the screen. Then click on the Class Index button. Once clicked, a list ordered alphabetically of all classes defined in OpenFOAM® is displayed. The inheritance diagram of any class along its public member functions and derived classes are obtained by simply clicking on the class name appearing in the list. Doxygen is used to quickly browse all source files as well as checking all the properties of the classes and namespaces. Basically the most common information to look for are class inheritances and public member functions as well as public class constructors.

(a)

Using the Doxygen documentation find the class definition of the following type of data:

Foam::face

Foam::cell

Foam::fvMesh

Foam::fvMatrix

(b)

Find the parent classes for each of the classes of (a).

(c)

Find the public constructors for each of the classes defined in (a).

(d)

Find all the public member functions defined in each of the classes of (a).

(e)

Find all the public member functions defined in the parent class of each of the classes of (a).

Exercise 2

Run testDiffusion (which is available as a test case with uFVM) for one iteration, then

(a)

Use ‘cfdGetCoefficients’ to get the global matrix data structure and compare it to that shown in Fig. 5.18.

(b)

Use cfdGetMesh to get a reference to the Mesh object and find the definition of a face, a cell and a vertex.

References

1.

Blazek J (2005) Computational fluid dynamics: principles and applications. Elsevier, Amsterdam

2.

Ferziger JH, Peric M (2002) Computational methods for fluid dynamics, 3rd edn. Springer, BerlinMATHCrossRef

3.

Versteeg HK, Malalasekera W (2007) An introduction to computational fluid dynamics: the finite volume method. Prentice Hall, New Jersey

4.

Courant R, Friedrichs KO, Lewy H (1928) Über die partiellen Differenzengleichungen der Mathematischen Physik. Math Ann 100:32–74 (English translation, with commentaries by Lax, P.B., Widlund, O.B., Parter, S.V., in IBM J. Res. Develop. 11 (1967))

5.

Crank J, Nicolson P (1947) A practical method for numerical integration of solution of partial differential equations of heat-conduction type. Proc Cambridge Philos Soc 43:50–67MATHMathSciNetCrossRef

6.

Clough RW (1960) The finite element method in plane stress analysis. Proceedings of second ASCE conference on electronic computation, Pittsburg, Pennsylvania, 8:345–378

7.

Launder BE, Spalding DB (1972) Mathematical models of turbulence. Academic Press, Massachusetts

8.

Patankar SV (1967) Heat and mass transfer in turbulent boundary layers, Ph.D. Thesis, Imperial College, London University, UK

9.

Gosman AD, Pun WM, Runchal AK, Spalding DB, Wolfshtein M (1969) Heat and mass transfer in recirculating flows. Academic Press, London

10.

Runchal AK (1969) Transport processes in steady two-dimensional separated flows. Ph.D. Thesis, Imperial College of Science and Technology, London, UK

11.

Runchal AK, Wolfshtein M (1969) Numerical integration procedure for the steady-state Navier-Stokes equations. Mech Eng Sci II 5:445–453CrossRef

12.

Rhie CM, Chow WL (1983) A numerical study of the turbulent flow past an isolated airfoil with trailing edge separation. AIAA J 21:1525–1532

13.

Lilek Z, Peric M (1995) A fourth-order finite volume method with collocated variable arrangement. Comput Fluids 24(3):239–252MATHCrossRef

14.

Leonard BP (1988) Universal limiter for transient interpolation modeling of the advective transport equations: the ultimate conservative difference scheme. NASA Technical Memorandum 100916, ICOMP-88-11

15.

Baliga BR, Patankar SVA (1983) Control volume finite-element method for two-dimensional fluid flow and heat transfer. Numer Heat Transf 6:245–261MATH

16.

Vaughan RV (2009) Basic control volume finite element methods for fluids and solids. IISc research monographs series, IISc Press

17.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

18.

OpenFOAM Doxygen (2015) Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_6

6. The Finite Volume Mesh

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

A key ingredient in the implementation of the finite volume method is setting up the geometrical support framework for the problem at hand. This process starts with mesh generation, which replaces the continuous domain by a discrete one formed of a contiguous set of non overlapping elements or cells delimited by a set of faces, and the defining of the physical boundaries through the marking of the boundary faces. It continues with the computation of relevant geometric information for the various components of the computational mesh, and is completed by capturing the topology of these components, i.e., how they are related and located one with respect to the other. Thus the result of the domain discretization step is not only the set of non-overlapping elements and other related geometric entities and the generated information about their geometric properties, but also the topological information about their arrangement and relations. It is this combined information that defines the finite volume mesh. The objective of this chapter is to clarify the topological and geometric requirements of the finite volume mesh.

6.1 Domain Discretization

The discretization of the physical domain, or mesh generation, produces a computational mesh (Fig. 6.1) on which the governing equations are subsequently solved. The methods and techniques used for domain discretization have changed drastically over the last few decades [1, 2], and, nowadays, have become mostly automated [3–6]. Before reviewing the types of elements commonly used in a computational mesh, the characteristics and attributes that the mesh system should possess in order to be employed in the context of the finite volume method are first described. These attributes will be presented in the context of computing the gradient of a variable ϕ on both a structured and an unstructured triangular mesh.

Fig. 6.1

a Domain of interest, b domain discretized using a uniform grid system, and c domain discretized using an unstructured grid system with triangular elements

In general a geometric domain may be discretized using either a structured or an unstructured grid system. In a structured mesh, three dimensional elements are defined by their local indices (i, j, k). A structured grid system has many coding and performance advantages but suffers from a limited geometric flexibility. Additional flexibility in the generation of structured meshes can be achieved by employing multiple blocks to define the geometry, with a structured mesh generated for each block either independently from other blocks or jointly.

Another way to make the mesh generation more flexible is to avoid the use of structured grids with their implicit topological information, and to adopt an unstructured mesh with explicit topological information based on connectivity tables and geometric entity numbering.

Structured grids remained the staple of numerical simulation for a long time and it is only in the past two decades that unstructured grids became more popular [7]. Starting in early 1970s, interest in automatic mesh generation escalated as problem size increased and manual mesh generation became too time consuming [8]. The first methods were semi-automatic with an operator manually placing points in the computational domain and then, in a second step, using a computer to generate the mesh. Nowadays the whole process is fully automated with both points and elements generated automatically.

Most modern CFD codes have the ability to use unstructured grids in addition to a variety of hybrid multiblock grids [9]. OpenFOAM® [10] uses unstructured grids but can also use conforming and non-conforming multiblock grids [11]. The finite volume method will be presented here in the context of an unstructured grid system. However as the unstructured finite volume mesh requirements are defined, its characteristics will be compared to those of a structured grid system.

6.2 The Finite Volume Mesh

The discussion for the requirements of the finite volume mesh will be contextualized in terms of a simple problem, namely the computation of the gradient of an element field. The gradient will first be computed on a structured grid and then over an unstructured grid; the differences will help clarifying a number of issues.

6.2.1 Mesh Support for Gradient Computation

Many techniques can be used to compute the gradient of an element field, and these will form the subject of Chap. 9. The method adopted in this chapter is based on the Green-Gauss theorem [12, 13]. It is relatively straightforward and can be used for a variety of topologies and grids (structured/unstructured, orthogonal/nonorthogonal, etc.). The starting point is defining the average gradient over a finite volume element of centroid C and volume V C as

(6.1)

Then, using the divergence theorem, the volume integral is transformed into a surface integral yielding

(6.2)

where d S is the outward pointing surface vector. In the presence of discrete faces, Eq. (6.2) can be written as

(6.3)

Next the integral over a cell face is approximated using the mid-point integration rule to become equal to the interpolated value of the field at the face centroid multiplied by the face area, resulting in

(6.4)

By reviewing Eq. 6.4 and Fig. 6.2, it is clear that to compute the average of the gradient over the control element C, information about the face area and direction (S f ) is required, as well as information about the neighboring elements and the ϕ values at the element centroids $$ \left( {\phi_{C} ,\phi_{{F_{k} }} } \right) $$. This information is needed to compute the value of ϕ at the interface (ϕ f ), which will have to be interpolated in some fashion.

Fig. 6.2

Gradient computation

A profile for the variation of the dependent variable ϕ between nodal values is assumed, which basically introduces an approximation in the evaluation of the gradient. In all cases the value of ϕ f will have to be computed at each face centroid. Assuming a linear profile for the variation of ϕ between the elements C and F straddling the interface f, an approximate value for ϕ f , denoted by $$ \overline{\phi }_{f} $$, can be computed as

(6.5)

One way to calculate the weight factors $$ g_{F} $$ and $$ g_{C} $$ is given by

(6.6)

Other interpolation practices may be used some of which will be explained later in the chapter.

Example 1

Compute the gradient for the two fields given in Table 6.1 over the two-dimensional cell shown in Fig. 6.3 using the surface vector values given in the table.

Table 6.1

Geometric data for Example 1

Sf

V

Field (1)

Field (2)

C

37.8

1

6

1

(−2.4, −3.24)

1

10

2

(2.4, −3.48)

1

9

3

(4.1, −6.7)

1

5

4

(2.2, 3.7)

1

3

5

(−2.64, 2.9)

1

4

6

(−3.66, 6.82)

1

8

Fig. 6.3

A two dimensional cell for Example 1

Solution

For case 1, the field is constant with a value of 1, so the value of the gradient is expected to be 0.

This is actually a property of the surfaces of closed elements, provided they all are pointing outward (or inward) they always sum to zero.

For case 2 the gradient is computed as

6.3 Structured Grids

For a regular structured grid, every interior cell in the domain is connected to the same number of neighboring cells. These neighboring cells (Fig. 6.4) can be identified using the indices i, j, and (k) in the x, y, and (z) coordinate direction, respectively, and can be directly accessed by incrementing or decrementing the respective indices. This allows for lower memory usage since topological information is embedded in the mesh structure through the indexing system. This also leads to greater efficiency in coding, cache utilization, and vectorization. Structured grids were widely used in the development of the Finite Volume and Finite Difference methods.

Fig. 6.4

Local indices and topology

In a structured grid, one can associate with each computational cell an ordered set of indices (i, j, k), where each index varies over a fixed range, independently of the values of the other indices, and where neighboring cells have associated indices that differ by plus or minus one. Thus, if there are Ni, Nj, and Nk elements in the i, j, and k index direction, respectively, then the total number of elements in the domain is $$ {Ni * Nj * Nk} $$. In three-dimensional spaces, elements are hexagons with 6 faces and 8 vertices, with each interior element having 6 neighbors. In two-dimensions, elements are quadrilaterals with 4 faces and 4 vertices, with each interior element having 4 neighbors.

6.3.1 Topological Information

Global indices are generally used for building the full system of equations over the computational domain, while local indices are employed to define the local stencil for an element, information that is useful during the discretization process. In structured grid systems local indices are used interchangeably as global indices because they can be readily translated to global indices and vice versa, as illustrated in Fig. 6.5. In two dimensional spaces the relation between local indices (i, j) and the global index (n) is given by

(6.7)

and the corresponding global indices for the neighbors of cell (i, j) are obtained as

(6.8)

On the other hand, in three-dimensional spaces the relation is

(6.9)

and the corresponding global indices for the neighbors of cell (i, j, k) are given by

(6.10)

This greatly simplifies the access to the coefficients and the solution of the system of equations, since the coefficients constructed over the local stencil of a cell are basically used in the general system of equations with no need for a translational step between local and global indices as the mapping between them is readily available. This also applies to the geometric fields and the various conservation fields that are being resolved.

Fig. 6.5

Local versus global indices

Example 2

In a 5 × 7 structured grid find the global indices of the neighbors of the element C defined by the local index (3, 4).

Solution

For the defined mesh Ni = 5 and Nj = 7, the global index of element C(3, 4) is thus $$3+(4-1)*5=18$$, the neighbors of elements C in terms of their local and global indices are (2, 4) → 17, (4, 4) → 19, (3, 3) → 13, and (3, 5) → 23.

6.3.2 Geometric Information

As shown in Fig. 6.6, accessing the local geometric information around an element is quite simple. For element (i, j) the surrounding stored faces are S1(i, j), S2(i, j), S1(i + 1, j), and S2(i, j + 1). Since for any element the faces have to be pointing outward (see Fig. 6.6), then

(6.11)

while for other faces, the following applies:

(6.12)

The element field in a structured two or three dimensional mesh is also defined as an array of size $$ \left[ {Nx} \right]\left[ {Ny} \right] $$ or $$ \left[ {Nx} \right]\left[ {Ny} \right]\left[ {Nz} \right] $$, respectively. Thus accessing the element value and its neighbors is equally simple. The element field of a multi-dimensional system may also be defined using a one dimensional array, which in two dimensions will be of size $$ \left[ {Ni * Nj} \right] $$ and in three dimensions of size $$ \left[ {Ni * Nj * Nk} \right] $$. Representing a multi-dimensional field by a one-dimensional array, with values stored using the global indexing system, saves a lot of computer memory when a multi grid system is adopted.

Fig. 6.6

Geometric information

6.3.3 Accessing the Element Field

Accessing the field in a structured grid is as simple as using the indices of the element. Therefore, in a two-dimensional space, $$ \phi \left( {i,j} \right) $$ or $$ \phi_{i,j} $$ is the value of field ϕ at element (i, j). As shown in Fig. 6.7a the values of ϕ at the neighboring cells to (i, j) are, respectively, $$ \phi_{i + 1,j} $$, $$ \phi_{i - 1,j} $$, $$ \phi_{i,j + 1} $$, and $$ \phi_{i,j - 1} $$.

Fig. 6.7

Local versus discretization versus global indices. a Local indexing, b global indexing, and c discretization indexing

As mentioned above computing the gradient using Eq. (6.4) requires calculating the value of ϕ at each face of the finite volume (for our pseudo elements the front and back faces have the same value and thus will not be included in the computation). Thus in addition to the value of ϕ at point (i, j), the values of ϕ at the neighboring points (i + 1, j), (i − 1, j), (i, j + 1), and (i, j − 1) are also needed. In a structured grid this information is readily available and the value at the face is computed by simple interpolation between the values of ϕ at the centroids of the two volumes sharing the face. Using Eq. (6.5), the interpolated value at face (i +1/2, j) in terms of local indices can be written as

(6.13)

Details of the linear interpolation will be presented later in the chapter. Referring to Fig. 6.7a, the gradient at element (i, j) can be computed using local indexing as

(6.14)

while using a global indexing system, Fig. 6.7b, it becomes

(6.15)

It should be mentioned that S is the outward vector normal to the surface at the control volume face. Except at the domain boundaries, control volume faces are shared by two elements. Therefore the outward direction for one element will represent the inward direction for the other element. Thus to avoid duplicating surface vectors at interfaces, only one vector is computed and stored at an interface; the one in the direction of increasing i or j. The embedded features in a structured grid system allows for the correct direction to be chosen with no need to store any additional information. For any element (i, j), the surface with an index greater than i or j is positive while the surface with an index lower than i or j is multiplied by a negative sign. This explain the negative signs in Eqs. (6.11) and (6.14).

6.3.3.1 Discretization Indexing

In addition to local and global indexing, another type known as discretization indexing is sometimes used, where the fields and geometric quantities are defined in terms of their position or neighboring values. Referring to Fig. 6.7c, the gradient at element (i, j) can be computed using discretization indexing as

(6.16)

Thus the algorithm for computing the gradient could be written as

6.4 Unstructured Grids

Unstructured grids offer more flexibility in meshing a domain both in terms of the element types that can be used and in terms of where the elements can be concentrated. This flexibility, however, comes at the cost of additional complexity. In an unstructured mesh system, elements are numbered sequentially, as are faces, nodes, and other geometric quantities. This means that there is no direct way to link various entities together based on their indices alone. Thus local connectivity has to be defined explicitly starting with determining the geometric quantities for a particular element. In Fig. 6.8, for example, the neighbors of element 9 cannot be directly derived from its index. Similarly the bounding faces of element 9, or for that matter their nodes, cannot be guessed or derived from its index in the same way this can be done in a structured grid.

Fig. 6.8

Unstructured mesh global indexing

Therefore detailed topological information about neighboring elements, faces, and nodes is needed to complement the global indexing of the grid.

6.4.1 Topological Information (Connectivities)

As shown in Fig. 6.9, topological information is developed by explicitly constructing the local, Fig. 6.9a, and global, Fig. 6.9b, indices that define the geometric component connectivities (element to element, element to faces, faces to elements, element to nodes, etc.). To this end, the data structure of elements, faces, and nodes now include information about neighboring connections in terms of local and global indices.

Fig. 6.9

Element connectivity and face orientation using a local indices and b global indices

The gradient computation algorithm can now be expressed in terms of the discretization indices shown in Fig. 6.9a as

(6.17)

or in terms of the local numbers of the element faces shown in Fig. 6.9a as

(6.18)

where the “()” indicates the local index of the face. The gradient relation can be also written in terms of global indices representing the stored values at the element faces shown in Fig. 6.9b as

(6.19)

where the negative signs for terms of faces 23, 15, 11 and 10 are to be noted. While the local surface vector S is always assumed to be in the outward direction, this is not necessarily true, as only one normal vector is stored at any one face. A look at Fig. 6.9 shows that these specific stored surface vectors are actually pointing inward of element 9, thus the negative sign. Unlike structured grid systems where the correct direction can easily be obtained, in an unstructured grid the direction of the normal to the surface should somehow be stored. This will be detailed in the following section. In order to account for the vector direction, a sign function is used and the equation for the gradient is modified as

(6.20)

For faces, information about the straddling elements is what defines the topology of the face. Furthermore the orientation of the face can be defined in a standard fashion by indexing the elements in a specified order. In this case the normal vector at the interface between two elements is oriented from element 1 to element 2, which are also denoted in OpenFOAM® by the owner and neighbor elements, respectively, as shown in Fig. 6.10.

Fig. 6.10

Owners, neighbors, and faces for a 2D and b 3D elements

Therefore if the interface is considered with element 2, then it should be multiplied by a negative sign. Thus considering the faces that bound element 9, the connectivity information is defined as shown in Fig. 6.11.

Fig. 6.11

An example of face, element, and node connectivities for unstructured grids

The computation of the gradient can be done for every element. However as the flux $$ \overline{\phi }_{f} {\mathbf{S}}_{f} $$ at every interface is the same for the straddling elements with the difference being its sign, the computation of the gradient could proceed in a more efficient manner by computing the gradient over the entire domain (e.g., the entire domain shown in Fig. 6.12) rather than element by element. This is done by looping over all the faces in the computational domain and directly updating the value of the gradient for the elements straddling the interface by incrementing and decrementing the calculated flux from the gradient of element 1 and element 2, respectively.

Fig. 6.12

An unstructured mesh system

Therefore the algorithm on an unstructured grid for calculating a gradient field becomes

Algorithm for computing the gradient on an unstructured grid system

This basically yields the gradient at each element in the computational domain as per Eq. (6.20). The same algorithm could be used with a structured grid to reduce the computational cost.

Example 3

Write the connectivity arrays for elements 1 and 5, and faces 1, 7, 11 and 23 for the mesh shown in Figs. 6.13 and 6.14.

Fig. 6.13

An unstructured mesh for Example 2

Fig. 6.14

Surface vector direction at faces 1, 7, and 23 for Example 2

Solution

For elements, the neighbors are stored in the increasing index number of shared faces, and interior faces are stored in increasing index number, followed by boundary faces again stored in increasing index number.

element 5

neighbors 6 3

faces 12 13 15 16

element 1

neighbors 2 6 3 8 4

faces 1 3 5 7 14

For a face the owner is the element of lower index and the neighbor is the element of higher index. A Boundary face has only an owner. The direction of the surface vector associated with any face is oriented from owner to neighbor.

face 1

owner 1

neighbor 2

face 7

owner 1

neighbor 8

face 11

owner 7

neighbor 9

face 23 (a boundary face)

owner 8

neighbor -1 (a boundary face has no neighbor)

6.5 Geometric Quantities

In addition to topological data, the finite volume mesh incorporates information about its geometric entities, such as the volume of elements, the area of faces, the centroids of elements and faces, the alignment of faces with the vectors joining the centroids of the owner and neighbor elements (Fig. 6.15), etc. The calculations of some of these geometric quantities will be presented next. The type of elements that can be used in generating the mesh are first described, followed by the techniques employed for computing the geometric information.

Fig. 6.15

Angle between surface vector and vector joining the centroids of the owner and neighbor elements

6.5.1 Element Types

An element in the finite volume mesh is basically a polyhedron in a three-dimensional mesh (Fig. 6.16) or a polygon in a two-dimensional mesh (Fig. 6.17). The most widely used three-dimensional shapes, as displayed in Fig. 6.16, are tetrahedrons, hexahedrons, prisms, and in some cases general polyhedrons.

Fig. 6.16

Three-dimensional element types

Fig. 6.17

Three-dimensional face types or two-dimensional element types

The type of faces for these three-dimensional elements, which also represent the type of two-dimensional elements (Fig. 6.17), vary greatly, with the ones that are the most widely used being quadrilaterals, triangles and pentagons, though general polygons have also been adopted in some applications.

The computation of geometric factors for such elements and faces will now be detailed. It is worth noting that when working with a two-dimensional mesh the volume of the elements are considered to be the area of the two dimensional elements multiplied by a unit dimension in the off plane direction. Thus the techniques to compute the volume of elements of two-dimensional meshes are exactly those used in computing the surface area of faces of three-dimensional meshes. Other variables arising during discretization, which are solely dependent on geometric quantities, will be presented when needed.

6.5.2 Computing Surface Area and Centroid of Faces

The general shape of an element face in a three-dimensional finite volume mesh is a polygon, though triangular and quadrilateral faces are the most widely used. The computation of the surface vector and centroid follows the same procedure for all types of polygons. Basically a point is constructed within the polygon based on the average of all the points that define the polygon. This point is the geometric centre of the polygon $$ {\mathbf{x}}_{G} = \left( {x_{G} ,y_{G} ,z_{G} } \right) $$, which coincides with the centroid of the polygon $$ {\mathbf{x}}_{CE} = \left( {x_{CE} ,y_{CE} ,z_{CE} } \right) $$ only for some very special shapes, which include triangles. Therefore the geometric centre of k points forming a polygon is computed as

(6.21)

Using the geometric centre (Fig. 6.18) a number of triangles are formed with the centre as the apex for each side of the polygon. For each of the triangles the centroid (since for triangles $$ {\mathbf{x}}_{G} $$ and $$ {\mathbf{x}}_{CE} $$ coincide) and area are readily computed. The sum of their areas will give the total area of the polygon. For computing the centroid the area-weighted centroid (or geometric centre) of each sub-triangle are summed over the polygon and divided by the polygon area, yielding the centroid of the polygon. Mathematically this is computed as

(6.22)

Fig. 6.18

The geometric centre and centroid of a polygon

6.5.2.1 Surface of a Triangle

The area of a triangle is computed using vector product. The magnitude of the vector product of two vectors represents the area of the parallelogram formed by the two vectors. Thus the area of the triangle is half the magnitude of the vector product of the two vectors. Denoting the position vectors of the three vertices 1, 2, and 3 of the triangle shown in Fig. 6.19 by $$ {\mathbf{r}}_{1} $$, $$ {\mathbf{r}}_{2} $$, and $$ {\mathbf{r}}_{3} $$, respectively, the surface vector of the triangle can be computed as

(6.23)

and the magnitude of the area is given by

(6.24)

To know whether the surface vector is pointing outward, its dot product with the position vector that joins the centroid of the element CE to the centroid of the surface ce is computed. If the sign of the dot product is positive then the surface vector is pointing outward, otherwise it is pointing inward. The same approach may be used to discern the orientation of the surface vector in two dimensions.

Fig. 6.19

Surface vector and area magnitude of a triangle in a three dimensional space

For a two dimensional grid the surface area represents the volume of the control cell with a unit depth in the off-plane direction. Therefore the volume of a triangular cell in a two dimensional grid is calculated using

(6.25)

Note that the signed volume (or area) will be positive if the vertices 1, 2 and 3 are oriented counterclockwise around the triangle, otherwise it will be negative. Taking the absolute value of the right hand side of Eq. (6.25) will always result in the correct volume value.

Example 4

Compute the centroid and area of the polygon shown in Fig. 6.20 whose coordinates are displayed in Table 6.2.

Fig. 6.20

A polygonal element

Table 6.2

Coordinates of the polygonal element for Example 3

Node

1

2

3

4

5

x

1

2.4

2

0.4

0

y

6.4

4.0

0.2

0

4.0

Solution

For this polygon k = 5. Thus its geometric centre $$ G\left( {x_{G} ,y_{G} } \right) $$ is located at

The polygon is decomposed into 5 triangles of apex $$ G\left( {x_{G} ,y_{G} } \right) $$. The centroid of triangle 1 is located at

In a similar way the centroids of other triangles are found and are presented in Table 6.3.

Table 6.3

Coordinates of the triangles’ centroids

Triangle

1

2

3

4

5

x-centroid

1.52

1.85333

1.18666

0.52

0.72

y-centroid

4.44

2.37333

1.04

2.30666

4.44

The areas of the triangles are found using Eq. (6.25) and for triangle 1 is given by

In a similar way the areas for the other triangles are found and are presented in Table 6.4.

Table 6.4

Areas of the various triangles

Triangle

1

2

3

4

5

Area

2.244

2.14

2.62

2.104

1.932

The area of the polygon is found to be

The coordinates of its centroid can be obtained as

The difference between the geometric centre and centroid is clear.

6.5.2.2 Volume and Centroid of Elements

The general procedure followed to compute the volume and centroid of a general polyhedron is conceptually simple. The process starts by computing the location of the geometric centre of the polyhedron element and decomposing it into a number of polygonal pyramids. As shown in Fig. 6.21, each polygonal pyramid is formed of the geometric centre as the apex and a polygonal face of the element as the base, with its side faces being triangles.

Fig. 6.21

A sub-element pyramid

For a polygonal pyramid, the volume and centroid are readily computed. The volume is calculated as $$ \left( {1/3} \right) \times Base \times Height $$. The base is basically one of the surfaces of the element, while the sub-element pyramid centroid, measured from the centroid of the base, is situated at $$ 1/4 $$ of the line joining the centroid of the base to the apex of the pyramid. The volume of the polyhedron element is the sum of the volumes of the polygonal pyramids. As for the centroid it is computed as the volume-weighted average of the centroids of the pyramids. Mathematically this is computed from the following relations:

(6.26)

Since the centroid and volume of a polygonal pyramid are easily computed, this procedure allows accurate computations of both the volume and centroid of an element.

6.5.2.3 Face Weighting Factor

Consider the one dimensional finite volume mesh system shown in Fig. 6.22. The values of ϕ are known at the control volume centroids C and F, and are to be used to compute the value of ϕ at the interface f.

Fig. 6.22

One dimensional mesh system

A simple linear interpolation will result in the following formula:

(6.27)

where

(6.28)

The simplicity of this formula does not extend into multi-dimensional situations as in two or three dimensions the circumstances become a bit more complicated. In this case there is not a unique option for the definition of the geometric weighting factors. One choice would be to base the weighting factor on the respective volumes, such that

(6.29)

This however yields wrong results in certain cases, such as in the configuration shown in Fig. 6.23.

Fig. 6.23

Axisymmetric grid system

Another difficulty arises when the points C, f, and F are not collinear as depicted in Fig. 6.24a.

Fig. 6.24

Two dimensional control volume with the points C, f, and F being non collinear

A better alternative for such cases, as displayed in Fig. 6.24b, is to base the interpolation on the normal distances to the face, i.e., $$ Cf' $$ and $$ Ff'' $$. Thus the interpolation factor is computed as

(6.30)

where $$ {\mathbf{e}}_{f} $$ is the surface unit vector given by

(6.31)

Example 5

Compute the weighing factor using Eqs. (6.26) and (6.27) for the two triangular elements shown in Fig. 6.25 (Table 6.5).

Fig. 6.25

Two neighboring polygonal elements

Table 6.5

Coordinates of the triangular elements for Example 4

Node

1

2

3

4

x

0

1.2

1

2

y

0

0.4

1

0.1

Solution

To calculate the interpolation factor using Eq. (6.26) the volumes of the two elements are needed and are computed as

The calculation of $$ g_{f} $$ based on Eq. (6.27) is more involved. The centroids of the two control volumes are required and are calculated as

The face centroid is also required and is found to be

The surface vector is calculated as

The unit vector normal to the face becomes

The distance from the centroids of the control volumes to the face centroid are given by

The interpolation factor using Eq. (6.27) is found as

the difference in values is obvious.

6.6 Computational Pointers

6.6.1 uFVM

In ufvm, the processing of all geometric and topological data is performed in one routine denoted by cfdProcessOpenFoamMesh, which is executed right after reading the OpenFOAM® mesh with cfdReadOpenFoamMesh. Reading the OpenFOAM® mesh in its native form, requires reading the various files defining an OpenFOAM® mesh, namely and in that order, points, faces, owners, neighbours, and boundaries files.

In cfdProcessOpenFoamMesh the face geometry is initially processed (centroid, area and surface vector), as shown in Listing 6.1.

Listing 6.1

Processing of basic face geometry

This is followed by processing the basic element geometry (Listing 6.2). The element volume is computed by subdividing it into non-overlapping pyramids, whose geometric characteristics can be easily computed.

Listing 6.2

Processing of basic element geometry

6.6.2 OpenFOAM®

As OpenFOAM® [10] uses an unstructured grid platform, all its geometric entities, such as elements, volumes, areas, and centroids, as well as face weighting factors, have to be evaluated and stored. This section provides an overview of the geometric relations needed in the evaluation of the geometric quantities used in OpenFOAM®.

6.6.2.1 Area and Centroid of Faces

In order to evaluate areas and centers for a generic polygon face, the face is decomposed into a series of triangular faces. The overall polygon face metrics are calculated by summing up the properties of each triangular portion. Thus Eqs. (6.21)–(6.23) have to be applied for each computational cell.

OpenFOAM® constructs centers of faces and calculates their areas in the file “$FOAM_SRC/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C” in which the following function is defined (Listing 6.3):

Listing 6.3

Function used for defining centers and areas of faces

The function has three arguments with the first, defined as const, representing data read from files, while the second and third arguments designate returned lists of objects of dimensions equal to the number of faces in the domain, containing the centers (fCtrs) and areas (fAreas) of the polygonal faces, respectively.

The pointField data is a list of all mesh vertices with each vertex defined using three spatial coordinates. The second data needed is the face definition. In OpenFOAM® this is provided in faceList (Listing 6.4), which is a list of identities of the points defining the faces of the mesh.

Listing 6.4

List of the identities of points defining faces

Then a for loop is performed for each face. Inside the loop, the number of points describing the face and their identities are first read in order to access the coordinates of the corresponding vertices. When a face is defined by only three vertices, then direct calculations of its centroid location and area are performed, as shown in Listing 6.5.

Listing 6.5

Equations used in calculating the geometric center and area of a triangular face

In this case the face center fCtrs[facei] is evaluated directly using Eq. (6.21) with k = 3, while the face area is calculated using Eq. (6.23) where the symbol “^” represents vector product.

For a generic polygonal shape, the face is first decomposed into triangles. For that purpose, OpenFOAM® defines estimated centers for faces based on the average value of vertices defining the face, as displayed in Listing 6.6.

Listing 6.6

Compute estimated centers for faces

Listing 6.7 indicates that a loop over all faces is performed for calculating the geometric centers and areas of the triangles into which these faces are decomposed.

Listing 6.7

Decomposing the polygonal faces into triangles and calculating the geometric centers and areas of these triangles

This is done by finding the face center “c” of each triangle using Eq. (6.21) (the factor $$ 1/3 $$ is applied later), the face normal vector “n” and its magnitude “a” that defines the triangle area as stated by Eq. (6.23) (again the factor $$ 1/2 $$ will be applied later). All metrics of the decomposed triangles are then summed up and normalized in accordance with Eq. (6.22), where now the factors $$ 1/3 $$ and $$ 1/2 $$ are applied, as depicted in Listing 6.8.

Listing 6.8

Calculating the centroids and areas of faces

In case of a degenerate face, i.e., when “sumA < a very small number”, a rescue value is set for the face.

6.6.2.2 Volume and Centroid of Elements

After computing the normals, areas, and centers of faces, it is possible to evaluate the metrics of cells. Similar to faces, the basic idea for a polyhedral cell is to decompose it into a sum of tetrahedra elements. The operations that calculate volumes and centroids of elements are then defined in the file “$FOAM_SRC/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C” using the function shown in Listing 6.9.

Listing 6.9

Function used to calculate volumes and centers of elements

This function uses four arguments where the first two represent, respectively, centers and areas of faces. The remaining two arguments return objects containing centers and volumes of cells. As shown in Listing 6.10, the “for” loops are defined twice. This redundancy is related to the LDU addressing used in OpenFOAM®, which will be introduced and described in the Chap. 7.

Listing 6.10

Compute estimated cell centers

In order to calculate the cells centroids and volumes, the first step is the evaluation of $$ {\mathbf{x}}_{G} $$, the geometric centers of cells denoted in Listing 6.10 by cEst, using the first relation in Eq. (6.25). Once the $$ {\mathbf{x}}_{G} $$ values are obtained, calculations of the pyramids’ volumes and cell centroids proceed by applying Eq. (6.25) using the code displayed in Listing 6.11.

Listing 6.11

Calculating cell centers and volumes

In the above code, fCtrs corresponds to $$ {\mathbf{x}}_{CE} $$ while “cEst—fCtrs” corresponds to the distance vector $$ {\mathbf{d}}_{Gf} $$ displayed in Fig. 6.21. The final values are obtained, as shown in Listing 6.12, by dividing cell centroids by cell volumes and then dividing cell volumes by 3.

Listing 6.12

The final values of cell centroids and volumes

The mesh data structure for uFVM and OpenFOAM® will be described in detail in Chap. 7.

6.7 Closure

The geometric data defining a finite volume mesh were presented in this chapter. It was stressed that the finite volume mesh is not simply the set of non-overlapping elements and nodes. It also includes the set of all geometric quantities with information about their topologies. The collection of all this represents the infrastructure needed by the equation discretization method adopted in this book, namely the Finite Volume Method (FVM).

6.8 Exercises

Exercise 1

Compare the equations presented in the book to the ones used in OpenFOAM® for computing the interpolation weights at the faces, the owner-Neighbor element distances, and the non orthogonal coefficient. These can be found in OpenFOAM® using Doxygen [14] in the functions makeWeights(), makeDeltaCoeffs(), and makeNonOrthDeltaCoeffs().

Exercise 2

Write a program that reads an OpenFOAM® mesh and checks that for each element the sum of the surface vectors is zero.

Exercise 3

Start by reading a mesh into uFVM and then investigate the mesh structure (use m = cfdGetMesh to get access to the mesh data, and then investigate the structure of an element, a face, and a vertex).

References

1.

Thompson JF, Warsi Z, Mastin C (1985) Numerical grid generation. Elsevier Science Publishers, New York

2.

Cheng S, Dey T, Shewchuk JR (2012) Delaunay mesh generation. CRC Press, Boca Raton

3.

Thompson JF, Soni BK, Weatherill NP (eds) (1999) Handbook of grid generation, Chapter 17. CRC Press, Boca Raton

4.

George PL (1991) Automatic mesh generation. Wiley, New YorkMATH

5.

Frey P, George PL (2010) Mesh generation. Wiley, New York

6.

Bern M, Plassmann P (2000) Mesh generation. Handbook of computational geometry. Elsevier Science, North Holland

7.

Mavriplis DJ (1996) Mesh generation and adaptivity for complex geometries and flows. In: Peyret R (ed) Handbook of computational fluid mechanics. Academic Press, London

8.

Thompson JF, Soni BK, Weatherill NP (1998) Handbook of grid generation. CRC Press, Boca Raton

9.

Chappell JA, Shaw JA, Leatham M (1996) The generation of hybrid grids incorporating prismatic regions for viscous flow calculations. In: Soni BK, Thompson JF, Hauser J, Eiseman, PR (eds) Numerical grid generation in computational field simulations. Mississippi State University, MS, pp 537–546

10.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

11.

Mavriplis DJ (1997) Unstructured grid techniques. Ann Rev Fluid Mech 29:473–514MathSciNetCrossRef

12.

Lerner RG, Trigg GL (1994) Encyclopaedia of physics. VHC, New York

13.

Byron F, Fuller R (1992) Mathematics of classical and quantum physics. Dover Publications, Mineola

14.

OpenFOAM Doxygen (2015) Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_7

7. The Finite Volume Mesh in OpenFOAM® and uFVM

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

The implementation of the finite volume mesh can follow many directions whether in the definition of the mesh fields, the storing of the variables, or even in determining the connectivity relations. This chapter aims at outlining the design decisions that shape the implementation of two CFD codes, uFVM an educational unstructured Finite Volume code and OpenFOAM® an industrial-strength open source code. The two codes are thus presented, initially in terms of their data structure and memory management schemes, and then in terms of how cases are setup. Finally the format of the system of equations generated by each of the two codes are detailed. The reader will notice that while uFVM shares many of the implementation details with OpenFOAM®, its simplicity allows for the use of simpler implementation techniques and data structure.

7.1 uFVM

The unstructured finite volume code uFVM was written to illustrate the various numerical techniques and algorithms, which collectively form a CFD program. Furthermore its numerics are in many ways similar to those in OpenFOAM® [1], making it a good vehicle to understand and present the internals of OpenFOAM®. The main data structures used in uFVM generally mirrors those in OpenFOAM® especially in terms of mesh fields and boundary conditions. Still differences between uFVM and OpenFOAM® will be used to underline various options available to CFD coders and thus to better present some implementation details.

7.1.1 An OpenFOAM® Test Case

The uFVM code is capable of reading an OpenFOAM® mesh included as part of any OpenFOAM® test case. An OpenFOAM® test case is a directory that generally contains at least three folders. Figure 7.1 shows the innards of the cavity test case folder, which consists of the following three sub-folders:

Fig. 7.1

The cavity OpenFOAM® case

The ‘time’ directories contain initialization and boundary condition information about the fields used in the test case. It is also the folder where results for various time steps are stored. The name of each sub-folder refers to the time at which simulation was performed. For example, in the cavity tutorial shown in Fig. 7.1, the velocity field U and pressure field p are initialized from files in the ‘0’ folder 0/U and 0/p, respectively.

The system directory contains at least three files with information about the case setup, the schemes to be used, and the various solution parameters. These files are: (i) controlDict which is concerned with the general control parameters of the test case such as the simulation starting and ending times, the time step to be used, and required parameters for data output; (ii) fvSchemes in which the discretization schemes used in the simulation are defined; (iii) fvSolution that contains information related to the solution algorithms and relaxations used during simulation.

The constant directory contains information about relevant physical properties, e.g., transportProperties, and the data describing the grid system used within a folder denoted by polyMesh.

For the purpose of understanding the finite volume mesh structure in uFVM, attention will be focussed on the polyMesh folder in which the information needed to construct the finite volume mesh is defined.

7.1.2 The polyMesh Folder

The polyMesh subdirectory contains the following files:

points

The file points is a list of vectors denoting the cell vertices, with vertex 0 being the first vector in the list, vertex 1 the second vector, etc. The format of the points file is shown in Listing 7.1.

Listing 7.1

Storing vertices as vectors of coordinates x, y and z

An example points file is shown in Listing 7.2.

Listing 7.2

An example showing how vertices are stored

faces

The file faces represents a list of faces, with each face described by a list of indices to vertices in the points list, where again, the first entry in the list represents face 0, the second entry represents face 1, etc. The format of the faces file is shown in Listing 7.3.

Listing 7.3

Storing faces in the form of points of which the face is composed and their indices

Example of a faces file is shown in Listing 7.4.

Listing 7.4

An example showing how faces are stored

owners

The file owners is a list in which the owner of faces are stored (Listing 7.5). The position of the owner in the list refers to the face it belongs to. Thus, the owner of face 0 is the index stored in the first entry, the owner of face 1 is the index stored in the second entry, etc. The number of owners is equal to the total number of faces (interior + boundary faces).

Listing 7.5

The format used to store owners

The number of Elements is equal to the largest index of the owners.

An example of an owners file is shown in Listing 7.6.

Listing 7.6

An example showing how owners are stored

The total number of cells ( nCells ) in the domain can be found in the owners file header as shown in Listing 7.7.

Listing 7.7

Header of owners file

neighbours

A list of neighbor cell labels (Listing 7.8). The number of neighbors is basically equal to the number of interior faces.

Listing 7.8

The format used to store neighbors

An example of a neighbours file is shown in Listing 7.9.

Listing 7.9

An example showing how neighbors are stored

boundary

File boundary lists the boundaries of the domain, with the faces of each boundary type referred to as a patch and assigned a name. The type of each boundary patch (type) is declared along with its number of faces (nFaces) and the starting face (startFace), which refers to the index of the first face in the list (Listing 7.10).

Listing 7.10

Format of a boundary patch

An example of a wall-type boundary patch is depicted in Listing 7.11.

Listing 7.11

An example of a wall-type boundary patch

7.1.3 The uFVM Mesh

In uFVM an OpenFOAM® mesh is read using the cfdReadOpenFoamMesh script. The script starts by reading the points file into the arrays of struct nodes where the (x, y, z) data is stored. Then file faces is read and the indices of the nodes are stored into the arrays of struct faces. Information about the face patches is then read from the file boundary. Finally the files owners and neighbours are read and the struct elements is composed. The loaded data is processed to compute additional geometric and topological information in script cfdProcessOpenFoamMesh. The details of a mesh generated over an elbow and read by uFVM is shown in Listing 7.12.

Listing 7.12

Information uFVM can display about a mesh

As shown in Fig. 7.2 the mesh can be plotted using the cfdPlotMesh command.

Fig. 7.2

a Three dimensional and b two dimensional views of the mesh over an elbow displayed using the cfdPlotMesh command

Example of information stored in struct nodes is presented in Listing 7.13 by displaying values for the node of index 1.

Listing 7.13

An example of information related to a node

As shown, the centroid contains the coordinates of the node in question, while iFaces and iElements are lists of indices of the faces and elements, respectively, that are connected to the node.

Information stored in struct faces can be obtained in a similar way. For example, the attributes of the face indexed 3 are given by (Listing 7.14).

Listing 7.14

An example of information related to a face

The above example shows that the struct faces contains the list of indices of the nodes defining the face, the indices of the owner and neighbor to the face, the centroid of the face, its surface vector, and its area. In addition, the distance vector T joining the centroids of the owner and neighbor elements, the geometric factor gf , the distance vector CN from the owner element centroid to the surface centroid, and the normal distance to the wall walldist of the owner element centroid are also stored. Other components will be described later as needed. Moreover, it should be noted that the neighbor for a boundary face is set to −1.

As displayed in Listing 7.15 for the element with index 20, which is a boundary element, the struct elements contains three lists of indices for neighboring elements (iNeighbours), faces (iFaces), and nodes (iNodes).

Listing 7.15

An example of information related to an element

Listing 7.16

Script needed for uFVM to display selected elements [here elements (20) and (300)] highlighted on the mesh

The order of the element indices and faces indices are synchronized such that elements are related to faces in the same order, and boundary faces are defined at the end of the list of faces. The struct elements also stores information about the element centroid and its volume. The faceSign list indicates whether the element is an owner (+1) or neighbor (−1) for the respective faces.

Elements can be identified on the mesh as in Fig. 7.3 using the following command (Listing 7.16):

Fig. 7.3

A two dimensional view of the mesh over an elbow highlighting elements (20) and (300)

Information about element (20) were displayed above while the attributes of element (300), which has two boundary faces, are as shown in Listing 7.17.

Listing 7.17

An example of information related to element (300) with two boundary faces

Finally information about the various boundary patches, i.e., the list of the boundary faces is stored in struct boundaries. Each boundary array contains information about the starting index of the first boundary face, the number of boundary faces belonging to the patch, in addition to the physical type of the patch and its name. For the example considered, information about boundary patch {1} is shown in Listing 7.18.

Listing 7.18

An example of information stored for a wall boundary

Moreover, information about the first boundary face, for example, is obtained as shown in Listing 7.19.

Listing 7.19

Information about a boundary face

To be noted is the index of the first boundary face, which is 1300+1 since in Matlab® arrays start at index 1 while in the C computer language arrays start at index 0.

Thus to loop over the faces of a certain patch, the index of the starting face and the number of faces from the struct boundary associated with the said patch are needed. For example to loop over the faces of patch 2, the following script (Listing 7.20) can be used:

Listing 7.20

Looping over boundary patch faces

cfdGetFaceIndicesForBoundaryIndex is defined in Listing 7.21 as follows:

Listing 7.21

Indices of boundary faces for a specific patch

7.1.4 uFVM Geometric Fields

In addition to all data stored in the struct mesh, information about the model to be solved and the values of the fields of interest should be stored to be accessed when needed. Three types of locale can be identified and fields of different types can be defined on them. Namely for locale (Elements, Faces, and Nodes) and for types (scalars, vectors, and tensors). The various fields are first defined based on their locale.

7.1.4.1 The Element Fields

An element field is constructed using the following script (Listing 7.22):

Listing 7.22

Script needed to construct an element field

where theUserName is the name of the field, theLocale is the geometric entity over which it is defined (Elements, Faces, Nodes), theType defines the type of the array elements (Scalar or Vector), and finally the TimeStep indicates the relative time of the field (Step0, Step1, etc.). For example, the following script (Listing 7.23):

Listing 7.23

Example of setting up a vector field

sets up a vector field defined over Elements at time step 0, i.e., at the current time step.

As shown in Fig. 7.4, the array has the size of the NumberOfElements+theNumberOfBoundaryFaces since the element array will include the values defined for each element in the mesh in addition to each boundary face. The boundary face values represent boundary conditions for that field. These boundary values are grouped in terms of boundary patches.

Fig. 7.4

Size of the field array

Generally they can be accessed as follows: For example to initialize the boundary values of the UField at patch 1 to a value [1 0 0], the following should be written (Listing 7.24):

Listing 7.24

The script needed to initialize the boundary value of a field in a patch

where the statement in Listing 7.25 given by

Listing 7.25

Statement used to compute values over a locale

evaluates the values in theFormula over theLocale and returns and array of the appropriate length of type theType (Scalar or Vector).

7.1.4.2 The Face Fields

A face field is constructed with theLocale set to ‘Faces’ as (Listing 7.26)

Listing 7.26

Statement used to construct a face field

Again, as shown in Fig. 7.5, the length of the array is equal to numberOfFaces, which combines the numberOfInteriorFaces plus the sum of all boundary faces.

Fig. 7.5

Size of faces array

The boundary faces for any boundary patch can be accessed as (Listing 7.27)

Listing 7.27

Script to access the various arrays of struct faces

and the boundary elements for a scalar field can then be retrieved using Listing 7.28 as

Listing 7.28

Accessing the boundary elements of a scalar phi

7.1.4.3 The Node Field

The node field is a list where the indices of vertices of faces are stored. Each face is referred to by the indices of its vertices in the points list (Fig. 7.6). The position of the face in the list refers to the face index. Therefore face 0 is the first entry in the list, face 1 is the second entry in the list, and so on.

Fig. 7.6

A points array

7.1.5 Working with the uFVM Mesh

Looping over elements, interior faces, boundary faces, boundary elements, or even boundary patches are common operations that are performed during the discretization and solution cycles. It is worth reviewing the mechanisms that allow performing these operations readily.

7.1.5.1 Looping Over Elements

This is a simple loop to implement as the number of elements is already known and the elements are indexed from 1 to the numberOfElements (0 to numberOfElements-1 for OpenFOAM®). Also element fields are indexed in a similar fashion, so accessing them is as simple as accessing elements. Thus the loop is simply as shown in Listing 7.29.

Listing 7.29

Script used to loop over elements

To access the boundary elements, the script shown in Listing 7.30 is used.

Listing 7.30

Script used to access boundary elements

7.1.5.2 Looping Over Faces

The faces array is constructed so that all interior faces run through indices 1 to numberOfInteriorFaces followed by the boundary faces that are also arranged according to the boundary patch to which they belong. Thus looping over the interior faces is straight forward and is written as in Listing 7.31.

Listing 7.31

Script used to loop over interior faces

Looping over the boundary faces can be done as shown in Listing 7.32.

Listing 7.32

Script used to loop over boundary faces

If the interest is to loop over the boundary faces of a certain patch, then the loop runs from a start face defined in the boundary condition to nFaces also defined in the boundary condition. Thus a loop over the faces of boundary patch n would be written as depicted in Listing 7.33.

Listing 7.33

Script used to loop over boundary faces of a certain patch

The subroutine cfdGetFaceIndicesForBoundaryIndex is used to directly get the vector startFace: startFace+nFaces-1.

7.1.6 Computing the Gauss Gradient

Computing the gradient of an element field in uFVM, necessitates the use of many of the above routines. Function cfdComputeGradientGauss0, displayed in Listing 7.34, shows the details of the Gauss Gradient implementation.

Listing 7.34

Computing the Gauss gradient

The loop over the boundary faces in Listing 7.34 did not take into account the patches to which the boundary faces belong, rather it just looped over all boundary faces. A version that would loop over the various patches and then over their respective boundary faces would be written as shown in Listing 7.35.

Listing 7.35

Boundary faces contribution to gradient implemented by looping over the various patches and then over their respective boundary faces

7.2 OpenFOAM®

OpenFOAM® [1] uses a finite volume cell-centered discretization of the domain and handles unstructured mesh data format based on the so called face-addressing storage. The aim of this data structure is to provide maximum flexibility in the definition of unstructured grids in order to allow for the use of a general polyhedron shape.

As shown in Fig. 7.7, a polyhedron is a three-dimensional solid consisting of a collection of plane polygons, joined at their edges. Tetrahedra (polyhedra with four triangular faces) and Hexahedra (polyhedra with six faces), for instance, are polyhedra where the faces are made by polygons of three and four edges, respectively. The possibility to describe any three-dimensional shape and use it as a finite volume element for the discretization of the equations gives multiple advantages and flexibility during mesh generation.

Fig. 7.7

A polyhedron element

An efficient way to describe a mesh constructed using polyhedral elements is the face addressing. In face addressing the element shape is of no consequence to the equation discretization process, requiring the use of global addressing when forming the coefficients. (Details on the formation of coefficients from the local and global perspective will be detailed later on).

In OpenFOAM® the data for points, faces, and elements are stored in a number of lists (arrays), as shown in Fig. 7.8. The list of points contains the three dimensional spatial coordinates, defined as vectors, which correspond to the vertices of the actual mesh. The dimensional unit is the meter. Moreover each vertex has a label defined by the position in the list, and because of the use of the C++ computer language the label counting starts from zero.

Fig. 7.8

Points, faces, and elements lists in OpenFOAM®

The faces are defined by a list of vertex labels referring to points in which the ordering is such that each two adjacent points are connected by an edge. The face list is organized in a way that all internal faces appear first in the list followed by faces related to the first boundary, then faces related to the second boundary, and so on. Lists of boundary faces are also named patches. It is important to remember that internal faces belong to two cells while boundary faces belong to one cell only. Finally the element or cell list is defined by a list of indices, where the position in that list is the cell index, the first index at any position is the number of faces for that element, and the face indices at a given position represent the faces for that cell.

OpenFOAM® can read computational grids from any mesh generator software capable of writing the mandatory files needed by OpenFOAM®. As explained earlier, the mesh is named polyMesh and has to be defined with a set of proper files. These files are placed in the directory “constant/polyMesh”. Based on the previous description the names of the files whose contents are self-explanatory are given by

points

faces

owner

neighbour

boundary

In OpenFOAM® the entire boundary of the domain is described as a list of patches in the file boundary. The file boundary is a list of all defined patches containing a proper entry named dictionary with each patch declared using the patch name, its type, its number of faces (nFaces), and the starting face (startFace). The general syntax used is as written in Listing 7.36.

Listing 7.36

Script used to create a patch

An example of a boundary file with two boundary types is shown in Listing 7.37.

Listing 7.37

A boundary file with two boundary types

From a programming point of view it is worth giving a brief introduction of the C++ classes that handle the mesh and allow access to specific data.

The base class that handles the “low-level” structure is called primitiveMesh. It is a generic class that wraps the geometric information of the mesh without assuming any particular form of discretization. It is the basic class for low level information about the mesh.

Examples of some of the functions that are members of the primitiveMesh class are shown in Listing 7.38.

Listing 7.38

Some functions of the primitiveMesh class

As can be seen, this class allows obtaining specific data of the mesh (e.g., cell volume, cell centers, face centers, etc.). It is worth noting that the class itself does not recognize boundaries or domain interfaces. Boundaries and domain interfaces are defined in the polyMesh class, which is derived from the primitiveMesh class. In addition to possessing all the attributes of the derived class, the polyMesh class introduces the handling of boundary definition and information, as shown in Listing 7.39. Again this class does not require any particular discretization scheme.

Listing 7.39

Information that can be obtained from the polymesh class

While primitiveMesh and polyMesh are the basic classes of the polyhedral mesh, the fvMesh class is derived from polyMesh and adds the particular data and functions needed for the finite-volume discretization. Addressing information as well as boundary information and specific mesh data are accessible for finite volume discretization.

OpenFOAM® decomposes the boundary mesh into patches stored in a list designated by polyPatchList under the class polyBoundaryMesh. Then, similar to interior mesh, a specialized class denoted by fvBoundaryMesh is derived from polyBoundaryMesh that inherits its functionalities and expands on it to include specific functions and data needed for finite-volume discretization. As for internal discretization, a similar hierarchy of classes composed of primitivePatch, polyPatch, and fvPatch is defined for boundary discretization. These classes are specific for the boundary mesh and contain the geometric information of each boundary. But it is the fvPatch that is used to implement the boundary conditions during the finite volume discretization. Figure 7.9 presents a schematic of the basic mesh description used in OpenFOAM®.

Fig. 7.9

Schematic of the basic mesh description used in OpenFOAM® [1]

In a similar way the fvMesh is used to access all mesh functionalities. Thus, it is mainly with fvMesh and fvPatch that the discretization classes and functions interact.

Examples of codes for reading and accessing the main properties of a mesh within the OpenFOAM® framework are now presented.

To read a mesh, the fvMesh class that handles the finite volume mesh and discretization is needed along with a special constructor as shown in Listing 7.40.

Listing 7.40

Script to read a mesh in OpenFOAM®

The include statements in Listing 7.40 are required for initialization before reading the mesh files.

Once the fvMesh instantiation is constructed under the variable named mesh, the manipulation of the loaded mesh and collection of the necessary data for further programming can proceed, as shown in Listing 7.41.

Listing 7.41

Extracting data after reading a mesh in OpenFOAM®

To loop over the cell volumes, the dedicated class function for information on volumes should first be called (Listing 7.42). This is accomplished via

Listing 7.42

Getting information on volumes

and then a loop over the cell volumes can be performed as shown in Listing 7.43.

Listing 7.43

Looping over all cell volumes

In OpenFOAM® the standard “for” loop is replaced by a more compact syntax using a macro definition named forAll (Listing 7.44) defined in the UList.H file as

Listing 7.44

Script used to replace the standard “for” loop by the macro forAll

In a similar way access to other mesh information can be performed as shown in Listing 7.45.

Listing 7.45

Script used to access mesh information

For boundary patches the access procedure is similar except that now each patch has its own class definition, and the full list of patches is defined in the fvBoundaryMesh class containing the fvPatches list. Therefore to access boundary data the following is used (Listing 7.46):

Listing 7.46

Accessing data on boundary patches

7.2.1 Fields and Memory

Within the OpenFOAM® generic framework, lists, arrays, and in general containers of different types and sizes can be defined. For a given mesh and computational structure, it would be useful to define a specific class capable of combining fields, lists, and vectors directly with the mesh. A useful class that satisfies this requirement is the template class GeometricField<Type,…>. Each data defined using this class is strictly related to the mesh dimensions, both for the boundaries and interior domain (be it the number of elements, the number of interior faces or even the number of interior vertices).

In general the template class GeometricField<Type,…> stores the following data structure based on three main different characteristics of the mesh:

volField<Type> A field defined at cell centers;

surfaceField<Type> A field defined on cell faces;

pointField<Type> A field defined on cell vertices.

The class also inherits the following properties:

Dimensions: OpenFOAM® provides a useful feature in handling fields under the class GeometricField. OpenFOAM® associates with each field a dimension (meter, kg, seconds, etc.) characterizing the physical meaning of the variable. Based on that all operations carried out with GeometricField have to be performed with fields of the same dimension (e.g., velocity can be summed up with velocity not pressure) otherwise a runtime error transpires during execution. Moreover the dimension of any new field defined as a combination of existing fields in GeometricField, is automatically generated by OpenFOAM® through applying the same algebraic relation utilized to generate the new field on the dimensions of the used fields (e.g., dividing a mass field with a volume field results in a field having the dimension of density).

InternalField: This is a repository of size equal to the size of the internal mesh properties (cell centers, vertices, or faces) in which internal information of a defined field is stored.

BoundaryField: contains all information pertinent to a defined variable at the boundary. A list of patches is developed and each field is defined for the patches of the boundary with the name GeometricBoundaryField. Operations can be performed either on the full set of boundaries or on a specific patch using fvPatchField.

Mesh: Being a class strictly related to the mesh, each GeometricField contains a reference to the corresponding mesh.

Time Values and Previous Values: This class is required to handle the specific field during simulation. It stores information of the previous two time steps for second order accuracy in time.

In the following, examples on the use of the specific class GeometricField to access the main properties of a field associated with a mesh are provided.

In the first example it is required to define the two variables U and T, representing a velocity and a temperature field, respectively, at the cell center of the mesh. This will be done using the templates of the specialized class GeometricField, which supports scalars, vectors, and tensors data type. The script used is shown in Listing 7.47 in which one of the several constructors of the class GeometricField is used (other constructors can be found in the header file of the specific class GeometricField.H).

Listing 7.47

Script used to define the two variables U and T in OpenFOAM®

As can be seen in the code, both fields are linked to the mesh. Both require specifying the following four arguments: (i) field name, (ii) field dimension, (iii) initialization, and (iv) boundary conditions. Specific boundary conditions have to be defined for the field and in this case a zero order extrapolation (i.e., “zeroGradient”) is specified for the full set of boundaries and for both variables.

Similar constructors can be used for variables defined at faces of the mesh. For example, the script needed to define the mass flux (volume flow rate) field at cell faces is shown in Listing 7.48.

Listing 7.48

Script used to define the mass flux field at mesh faces

In this case the field is constructed with a scalar product between velocity (interpolated at the face) and face area vectors. This field represents the volume flow rate at control volume faces. It also represents the mass flow rate field for incompressible flows with a density value of one.

Once fields are defined, access to specific data in different parts of the mesh is possible as shown in the scripts below.

7.2.2 InternalField Data

Internal field data can be accessed (Listing 7.49) using

Listing 7.49

Accessing internal field data

7.2.3 BoundaryField Data

Boundary field data can be accessed (Listing 7.50) using

Listing 7.50

Accessing boundary field data

or in a more compact form via (Listing 7.51)

Listing 7.51

A more compact script to access boundary field data

7.2.4 lduAddressing

OpenFOAM® uses exclusively face addressing in its discretization loops and coefficients storage. It also uses arbitrary polyhedral elements in its meshes. A polyhedron element can have any number of faces with a neighbor element associated with each interior face. The storage of coefficients in OpenFOAM® is based on the face addressing scheme. In this approach, coefficients are stored following the interior face ordering, with access to elements and their coefficients, based on the owner/neighbor indices associated with interior faces. As mentioned in the previous section, the element with the lower index is the owner while the neighbor is the element with the higher index. For boundary faces the owner is always the cell to which the face is attached while no neighbor is defined by setting the neighbour index to −1. The list of owner or neighbor indices thus define the order in which the element-to-element coefficients are assembled for the various integral operators.

The above described scheme is denoted by lduAddressing and is implemented in the lduMatrix class displayed in Fig. 7.10 that includes 5 arrays representing the diagonal, upper, and lower coefficients and the lower and upper indices of the face owner and neighbor, respectively. In this scheme, owners represent the lower triangular part of the matrix (lower addressing) while neighbors refer to the upper triangular part (upper addressing). It is worth mentioning that given a face for an owner element the lower and upper addressing provide respectively the column and row where the coefficient of the face flux is stored in the matrix while it is the opposite for a neighbor cell. For the domain shown on the upper left side of Fig. 7.10, the owner and neighbor of each face are displayed in the lowerAddr() and upperAddr() array, respectively. The face number is the position of the owner or neighbor in the array plus one (since numbering starts with 0). Considering internal face number 4, for example, its related information is stored in the fifth row (in C++ indexing starts from 0) of the lower(), upper(), lowerAddr(), and upperAddr() array, respectively. The stored data indicate that its owner is element number 2 (lowerAddr() array), its neighbor is element number 4 (upperAddr() array), the coefficient multiplying $$ \phi_{4} $$ in the algebraic equation for element number 2 is stored in the fifth row of the array upper(), and the coefficient multiplying $$ \phi_{2} $$ in the algebraic equation for element number 4 is stored in the fifth row of the array lower().

Fig. 7.10

The lduAddressing and lduMatrix

Thus the lduAdressing provides information about the addresses of the off diagonal coefficients in relation to the faces to which they are related. This means that while the computational efficiency for various operations on the matrix is high when they are mainly based on loops over all faces of the mesh, direct access to a specific row-column matrix element is difficult and inefficient. One example is the summation of the off-diagonal coefficients for each row given by

(7.1)

In this case the use of face addressing does not allow direct looping over the off-diagonal elements of each row and performing such operation requires looping over all elements because it can only be done, as shown in Listing 7.52, following a face based approach.

Listing 7.52

Summation of the off-diagonal coefficients

In Listing 7.52 ac is the sum of the off-diagonals coefficients, l and u are the upper and lower addressing while Lower and Upper stores the corresponding coefficients. As can be noticed the summation is performed looping through all the faces and the summation of each row is not sequential, depending only on the owner-neighbor numeration of the mesh.

So in general the lduAddressing introduces a more complex handling of the matrix operations and it will be reflected also in the implementation of linear solvers but with the advantage of higher computational speed.

7.2.5 Computing the Gradient

The script used to compute the Green-Gauss gradient in OpenFOAM® is shown in Listing 7.53.

Listing 7.53

Script used to compute a gradient field in OpenFOAM®

The small introduction reported above is neither intended as a replacement of OpenFOAM® user’s manual [1] nor a replacement of a C++ manual. The purpose of the above presentation is to introduce the reader to the philosophy and general concepts that are useful for a quick understanding of the OpenFOAM® framework. Despite the generality of presentation, the described syntax introduced one of the main important data defined within OpenFOAM® that are necessary for writing a complete solver, which will be described in later chapters.

7.3 Mesh Conversion Tools

There are many tools capable of converting mesh files from a variety of format to the OpenFOAM® format. Some of these tools are as follows [1]:

ansysToFoam: Converts an ANSYS input mesh file, exported from I-DEAS, to OpenFOAM® format.

cfx4ToFoam: Converts a CFX 4 mesh to OpenFOAM® format.

datToFoam: Reads in a datToFoam mesh file and outputs a points file. Used in conjunction with blockMesh.

fluent3DMeshToFoam: Converts a Fluent mesh to OpenFOAM® format.

fluentMeshToFoam: Converts a Fluent mesh to OpenFOAM® format including multiple region and region boundary handling.

foamMeshToFluent: Writes out the OpenFOAM® mesh in Fluent mesh format.

foamToStarMesh: Reads an OpenFOAM® mesh and writes a PROSTAR (v4) bnd/cel/vrt format.

foamToSurface: Reads an OpenFOAM® mesh and writes the boundaries in a surface format.

gambitToFoam: Converts a GAMBIT mesh to OpenFOAM® format.

gmshToFoam: Reads.msh file as written by Gmsh.

ideasUnvToFoam: I-Deas unv format mesh conversion.

kivaToFoam: Converts a KIVA grid to OpenFOAM® format.

mshToFoam: Converts.msh file generated by the Adventure system.

netgenNeutralToFoam: Converts neutral file format as written by Netgen v4.4.

plot3dToFoam: Plot3d mesh (ascii/formatted format) converter.

sammToFoam: Converts a STAR-CD (v3) SAMM mesh to OpenFOAM® format.

star3ToFoam: Converts a STAR-CD (v3) PROSTAR mesh into OpenFOAM® format.

star4ToFoam: Converts a STAR-CD (v4) PROSTAR mesh into OpenFOAM® format.

tetgenToFoam: Converts .ele and .node and .face files, written by tetgen.

writeMeshObj: For mesh debugging: writes mesh as three separate OBJ files which can be viewed with e.g. javaview.

7.4 Closure

The chapter overviewed the realization of the FVM in a computer code by explaining several implementation attributes of the uFVM and OpenFOAM® CFD codes. The two codes were presented in terms of their data structure, memory management schemes, and case setup. The next chapter will detail the finite volume second discretization step as applied to the diffusion flux.

7.5 Exercises

Exercise 1

For the configuration shown in Fig. 7.11

Fig. 7.11

The rectangular domain discretized with an unstructured grid used for Exercise 1

(a)

Write the owner and neighbor for each interior face and use it to write the owners and neighbors lists.

(b)

Build the connectivity array for each element by looping over each of the interior faces using the owner-neighbor information; this is the coefficient connectivity used in uFVM.

(c)

Build the coefficients ldu addressing connectivity used in OpenFOAM®.

Exercise 2

Using the uFVM (MATLAB®) code, read the elbow mesh (available at the book website) and then do the following:

(a)

Write a script to loop over all the elements of the domain and print out for each element its index, and the indices of its faces in the following format “element[i] → faces[k l m n…]”

(b)

Declare and array phi as an element field (size = 1, Number of elements + Number of boundary faces), and initialize it using the following formula: ϕ(x, y, z) = 10xy + 5y ².

(c)

Declare a new element array of type vector (size 3, Number of elements + Number of boundary faces) and use it to compute the gradient of phi, using the gauss theorem i.e.,

which can be written as follows for the mesh data used:

Exercise 3

Use blockMesh to setup a uniform mesh similar to the one in Fig. 7.12 for L = 1. In OpenFOAM® and then in uFVM do the following:

Fig. 7.12

A two dimensional domain generated with blockMesh

(a)

Write a program to read the mesh and loop over all boundary patches. Then for each patch print the centroid and normal vector of its faces.

(b)

Modify the program to define a volumeScalarField T. Set the values for T at element centroids and at the boundaries to 10x ² y ², where x and y are the coordinates of the element centroids and for the case of the boundary the centroids of the boundary faces.

(c)

Write a program to compute the gradient of T and compare its value with the analytical solution.

Exercise 4

(a)

Find in OpenFOAM® using Doxygen [2], the class definition of the data types points, face, and cell.

(b)

Loop over all interior faces (using forAll) and for each face write the owner, neighbor, and centroid.

(c)

Loop over all elements and write for each element the value of the cubic root of its volume and its centroid.

(d)

Loop over all boundary faces and write for each face the owner (parentCell) and centroid.

(e)

Define a surfaceScalarField and set its value to be equal to the x component for interior faces and the y component for boundary faces.

(f)

Find the member function of the surfaceScalarField (GeometricField<>) that returns the old time values.

References

1.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

2.

OpenFOAM Doxygen (2015) Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

Part II
Discretization

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_8

8. Spatial Discretization: The Diffusion Term

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter describes in detail the discretization of the diffusion term represented by the spatial Laplacian operator. It is investigated separately from the convection term, because convection and diffusion represent two distinct physical phenomena. Thus from a numerical point of view, they have to be handled differently, requiring distinct interpolation profiles with disparate considerations. The chapter begins with the discretization of the diffusion equation in the presence of a source term over a two-dimensional rectangular domain using a Cartesian grid system. The adopted interpolation profile for the variation of the dependent variable between grid points and the basic rules that should be satisfied by the coefficients of the discretized equation are discussed. The chapter proceeds with a discussion on the implementation of the Dirichlet, Von Neumann, mixed, and symmetry boundary conditions. The discretization over a non-Cartesian orthogonal grid is then introduced, followed by a detailed description of the discretization on non-orthogonal structured and unstructured grid systems. The treatment of the non-orthogonal cross-diffusion contribution, which necessitates computation of the gradient, is clarified. Then anisotropic diffusion is introduced and handled following the same methodology developed for isotropic diffusion. The under-relaxation procedure needed for highly non-linear problems is outlined. The chapter ends with computational pointers explaining the treatment of diffusion in both uFVM and OpenFOAM®.

8.1 Two-Dimensional Diffusion in a Rectangular Domain

A simple rectangular domain with a regular Cartesian grid, as shown in Fig. 8.1, is first considered. The aim is to discretize, on this domain, the steady-state diffusion equation given by

(8.1)

where ϕ denotes a scalar variable (e.g., temperature, mass fraction of a chemical species, turbulence kinetic energy, etc.), Q ϕ the generation of ϕ per unit volume within the domain, and $$ \Gamma ^{\phi } $$ the diffusion coefficient. The equation can be written more generally in term of a diffusion flux J ϕ,D as

(8.2)

where J ϕ,D is defined as

(8.3)

Fig. 8.1

A uniform Cartesian grid

Following the first stage discretization presented in Chap. 5, Eq. (8.1) can be formulated as

(8.4)

The expanded form of the above equation can be written as

(8.5)

For the uniform Cartesian grid of Fig. 8.1, the surface vectors normal to the element faces are given by

(8.6)

Thus for the east face the diffusion flux is found to be

(8.7)

Following the discrete conservation equation for one integration point discussed earlier, the discrete form of the diffusion flux can be written as

(8.8)

To determine the FluxC e , FluxF e , and FluxV e coefficients, a profile describing the variation of ϕ between the centroids of the two elements sharing the face, where the gradient has to be computed, is required. Assuming that ϕ varies linearly between cell centroids (Fig. 8.2), the gradient at face e along the i direction may be written as

(8.9)

Fig. 8.2

Interpolation profile at face e and slope of gradient

Substituting into Eq. (8.8), the discretized form of the diffusion flux along face e is obtained as

(8.10)

Taking

(8.11)

where d CE is the distance vector between the centroids of elements C and E, the coefficients become

(8.12)

A similar procedure applied to face w yields

(8.13)

where now

(8.14)

and

Similar expressions may be written along faces n and s and are given by

(8.15)

where

(8.16)

and

(8.17)

Substituting into Eq. (8.5), the algebraic form of the diffusion equation is obtained as

(8.18)

where

(8.19)

or, more compactly, as

(8.20)

with

(8.21)

where the subscript F denotes the neighbors of element C (E, W, N, S), and the subscript f denotes the neighboring faces of element C (e, w, n, s).

8.2 Comments on the Discretized Equation

A proper discretization method should result in a discretized algebraic equation that reflects the characteristics of the original conservation equation. The properties of the discretization techniques were introduced in the previous chapter and two additional rules that the coefficients of the discretized equation have to satisfy are presented next.

8.2.1 The Zero Sum Rule

Looking back at the discretization process, the first major approximation made was the linear profile assumption for the variation of ϕ between the centroids of the elements straddling the element face. The reader might ask why to use a first order rather than a higher order profile. To answer this question, a one dimensional configuration with no source term is considered. Under these conditions the discretized equation reduces to

(8.22)

where

(8.23)

In the absence of any source or sink within this one dimensional domain, the transfer of ϕ occurs by diffusion only and is governed by Fourier’s law (elliptic equation), i.e., in the direction of decreasing ϕ. As such, the value of ϕ e or ϕ w should lie between the values ϕ C and ϕ E or ϕ C and ϕ W , respectively, which is guaranteed by the linear profile. A second order profile (e.g., a parabolic profile) may result in a value at the face that is higher or lower than the values at the centroids of the cells straddling the face, which is unphysical. The same is true for other higher order profiles. If the discretization scheme is to guarantee physical results, then a linear profile should be used. Moreover, the adopted profile becomes less important as the size of the element decreases, since all approximations are expected to yield the same analytical solution in the limit when the size of the element approaches zero. Furthermore, in the absence of any source term, the multi-dimensional heat conduction equation reduces to,

(8.24)

This implies that ϕ and ϕ + constant are solutions to the conservation equation. A consistent discretization method should reflect this property through its discretized equation and the discretized equation should fulfill

(8.25)

which is actually satisfied by the discretized equation. The above equation, which is valid in the presence or absence of a source/sink term as revealed by Eq. (8.19), may be written as

(8.26)

or as

(8.27)

Thus ϕ C can be viewed as the weighted sum of its neighbors, and in the absence of any source term it should always be bounded by these neighboring ϕ F values. When a source term is present, i.e., when $$ S_{C}^{\phi } \ne 0, \, \phi_{C} $$ does not need to be bounded in this manner, and can over/undershoot the neighboring values, but this is perfectly physical. The extent of over/under shoot is determined by the magnitude of $$ S_{C}^{\phi } $$ with respect to the size of the coefficients at the neighboring nodes (a F ).

8.2.2 The Opposite Signs Rule

The above derivations demonstrated that the coefficients a C and a F are of opposite signs. This is of physical significance implying that as the value of ϕ F is increased/decreased, the value of ϕ C is expected to increase/decrease. This is basically related to boundedness suggesting that a sufficient condition for this property to be satisfied is for the neighboring and main coefficients to be of opposite signs. If not, then the boundedness property may not be enforced.

8.3 Boundary Conditions

It is well known that the analytical solution to any ordinary or partial differential equation is obtained up to some constants that are fixed by the applicable boundary conditions to the situation being studied. Therefore, using different boundary conditions will result in different solutions even though the general equation remains the same. Numerical solutions follow the same constrain, necessitating correct and accurate implementation of boundary conditions as any slight change in these conditions introduced by the numerical approximation leads to a wrong solution of the problem under consideration.

Boundary conditions will be discussed as deemed relevant to the terms being discretized. For conduction/diffusion problems Dirichlet, Neumann, mixed, and symmetry boundary condition types are encountered, which are detailed next.

Boundary conditions are applied on boundary elements, which have one or more faces on the boundary. Discrete values of ϕ are stored both at centroids of boundary cells and at centroids of boundary faces.

Let C denotes the centroid of the boundary element shown in Fig. 8.3 with one boundary face of centroid b and of surface vector S b pointing outward. As before, the discretization process over cell C yields

(8.28)

Fig. 8.3

Value specified boundary condition

The fluxes on the interior faces are discretized as before, while the boundary flux is discretized with the aim of constructing a linearization with respect to ϕ C , thus

(8.29)

The specification of boundary conditions involves either specifying the unknown boundary value ϕ b , or alternatively, the boundary flux $$ {\mathbf{J}}_{b}^{\phi ,D} $$. Using Eq. (8.18), the discretized equation at a boundary element for the different boundary condition types of diffusion problems are derived next.

8.3.1 Dirichlet Boundary Condition

A Dirichlet boundary condition is a type of boundary condition that specifies the value of ϕ at the boundary, i.e.,

(8.30)

For this case

(8.31)

yielding

(8.32)

with

(8.33)

Thus for element C shown in Fig. 8.3 the a E coefficient is zero reducing the discretized equation to

(8.34)

where

(8.35)

and

(8.36)

The following important observations can be made about the discretized boundary equation:

1.

The coefficient a b is larger than other neighbor coefficients because b is closer to C and consequently has a more important effect on ϕ C .

2.

The coefficient a C is still the sum of all neighboring coefficients including a b . This means that for the boundary element $$ \sum\limits_{F{\sim}NB\left( C \right)} {\left| {a_{F} } \right|/\left| {a_{C} } \right| < 1} $$ giving the second necessary condition to satisfy the Scarborough criterion, thus guaranteeing, at any one iteration, the convergence of the linear system of equations via an iterative solution method.

3.

The a b ϕ b product (=FluxV b ) is now on the right hand side of the equation, i.e., part of b C , because it contains no unknowns.

8.3.2 Von Neumann Boundary Condition

If the flux (or normal gradient to the face) of ϕ is specified at the boundary (Fig. 8.4), then the boundary condition is denoted by a Neumann boundary condition. In this case the specified flux is given by

(8.37)

which is, in effect, the flux $$ {\mathbf{J}}_{b}^{\phi ,D} $$, since

(8.38)

where now

(8.39)

Fig. 8.4

Flux specified boundary condition

Here the flux components are assumed to be positive when they act in the same direction as the coordinate system used.

Thus q b may directly be included in Eq. (8.18) to yield the following discrete equation for the boundary cell C:

(8.40)

where

(8.41)

The following important points can be made about the above discretized equation:

1.

A Von Neumann boundary condition does not result in a dominant a C coefficient.

2.

If both $$ q_{b} $$ and $$ S_{C}^{\phi } $$ are zero, then $$ \phi_{C} $$ will be bounded by its neighbors. Otherwise, $$ \phi_{C} $$ can exceed (or fall below) the neighbor values of $$ \phi $$, which is admissible. If $$ \phi $$ is temperature, for example, then $$ q_{b} $$ represents the heat flux applied at the boundary. Therefore if heat is added at the boundary, then the temperature in the region close to the boundary is expected to be higher than that in the interior.

3.

Once $$ \phi_{C} $$ is computed, the boundary value $$ \phi_{b} $$ may be computed using

(8.42)

4.

Finally the Von Neumann condition can be considered as a natural boundary condition for the Finite Volume method since, for the case where the specified flux is zero, nothing needs to be done in terms of discretization for the face, while a specified value of zero (Dirichlet condition) will still require the discretization to be carried out.

8.3.3 Mixed Boundary Condition

The mixed boundary condition, schematically depicted in Fig. 8.5, refers to the situation where information at the boundary is given via a convection transfer coefficient (h ∞) and a surrounding value for $$ \phi (\phi_{\infty } ) $$ as

(8.43)

which can be rewritten as

(8.44)

from which an equation for $$ \phi_{b} $$ is obtained as

(8.45)

Fig. 8.5

Mixed type boundary condition

Substituting $$ \phi_{b} $$ back in Eq. (8.43), the flux equation is transformed to

(8.46)

where now

(8.47)

Using the flux term given by Eq. (8.47) in the discretized equation of the boundary element C, the modified equation is found to be

(8.48)

where

(8.49)

8.3.4 Symmetry Boundary Condition

Along a symmetry boundary the normal flux to the boundary of a scalar variable $$ \phi $$ is zero. Therefore a symmetry boundary condition is equivalent to a Neumann boundary condition with the value of the flux set to zero (i.e., FluxC b  = FluxV b  = 0). Thus the modified equation along a symmetry boundary condition can be deduced from Eqs. (8.40) and (8.41) by setting q b to zero and is given by

(8.50)

where

(8.51)

8.4 The Interface Diffusivity

In the above discretized equation, the diffusion coefficients $$ \Gamma _{e}^{\phi } ,\Gamma _{w}^{\phi } ,\Gamma _{n}^{\phi } $$, and $$ \Gamma _{s}^{\phi } $$ have been used to represent the value of $$ \Gamma ^{\phi } $$ at the e, w, n and s faces of the element, respectively. When the diffusion coefficient $$ \Gamma ^{\phi } $$ varies with position, its value will be known at the cell centroids E, W, … and so on. Then a prescription for evaluating the interface value is needed in terms of values at these grid points. The following discussion is, of course, not relevant to situations of uniform diffusion coefficient.

The discussion may become clearer if the energy equation is considered, in which case the diffusion coefficient represents the conductivity of the material used and $$ \phi $$ denotes the temperature. Non-uniform conductivity occurs in non-homogeneous materials and/or when the thermal conductivity is temperature dependent. In the treatment of the general differential equation for $$ \phi $$, the diffusion coefficient $$ \Gamma ^{\phi } $$ will be handled in the same way. Significant variations of $$ \Gamma ^{\phi } $$ are frequently encountered for example, in turbulent flow, where $$ \Gamma ^{\phi } $$ may stand for the turbulent viscosity or the turbulent conductivity. Thus, a proper formulation for non-uniform $$ \Gamma ^{\phi } $$ is highly desirable.

A simple approach for calculating the interface conductivity is the linear profile assumption for the variation of $$ \Gamma ^{\phi } $$, between point C and any of its neighbors. Thus, along the east face the value of $$ \Gamma ^{\phi } $$, is obtained as

(8.52)

where the interpolation factor g e is a ratio in terms of distances between centroids given by

(8.53)

Hence for a Cartesian grid if the interface is midway between the grid points, g e would be 0.5, and $$ \Gamma _{e}^{\phi } $$ would be the arithmetic mean of $$ \Gamma _{C}^{\phi } $$ and $$ \Gamma _{E}^{\phi } $$. Similar coefficients can be defined for other faces as

(8.54)

Therefore it is sufficient to calculate the coefficients of each surface of an element only once. Moreover, the use of distances instead of volumes will lead to the same interpolation factors as the grid here is Cartesian.

This basic approach leads to rather incorrect implications in some cases and cannot accurately handles, for example, abrupt changes of conductivity that may occur in composite materials. Fortunately, a much better alternative of comparable simplicity is available. In developing this alternative, it is recognized that the local value of conductivity at an interface is not of primary concern. Rather, the main objective is to obtain a good representation of the diffusion flux J ϕ,D at the interface [1].

For the one dimensional problem shown in Fig. 8.6, it is assumed that the element C is composed of a material having a thermal conductivity $$ \Gamma _{C}^{\phi } $$, while element E is made of a material of thermal conductivity $$ \Gamma _{E}^{\phi } $$. For the non-homogeneous slab between points C and E, a steady one-dimensional analysis (without sources) results in (the flux on either side of the interface e is supposed to be the same)

(8.55)

Fig. 8.6

Interpolation of properties at element faces

Hence the effective conductivity for the slab is found to be

(8.56)

When the interface is halfway between C and E (g e  = 0.5), Eq. (8.56) reduces to

(8.57)

which is the harmonic mean of $$ \Gamma _{C}^{\phi } $$ and $$ \Gamma _{E}^{\phi } $$, rather than the arithmetic mean.

It is important to note that the harmonic mean interpolation for discontinuous diffusion coefficients is exact only for one-dimensional diffusion. Nevertheless, its application for multi-dimensional situation has an important advantage. With this type of interpolation, nothing special need to be done when treating conjugate interfaces. Solid and fluid cells are simply treated as part of the same domain with different diffusion coefficients stored at the cell centroids. By calculating the face diffusivity as the harmonic-mean of the values at the centroids sharing the face, the diffusion flux at the conjugate interface is correctly computed.

Example 1

The heat conduction in the two-dimensional rectangular domain composed of two materials shown in Fig. 8.7 is governed by the following differential equation:

where T represents temperature. For the thermal conductivities (k) and boundary conditions displayed in the figure:

Fig. 8.7

Conduction heat transfer in a two dimensional rectangular domain

(a)

Derive the algebraic equations for all the elements shown in the figure.

(b)

Using the Gauss-Seidel iterative method discussed in Chap. 4 , solve the system of equations obtained and compute the cell values of T.

(c)

Compute the values of T at the bottom, right, and top boundaries.

(d)

Compute the net heat transfer through the top, bottom, and left boundaries and check that energy conservation is satisfied.

Solution

The first step is to determine the geometric quantities that are needed in the solution. The coordinates of the various nodes are found to be

The distance between nodes are computed as

The size of the elements are given by

The computed volumes of the various cells are obtained as

The interpolation factors needed to find values at element faces are calculated as

The thermal conductivity values over the domain are given by

while values at the element faces are found to be

Using the above values, the discretized algebraic equations for all elements are derived next.

Element #1

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The west and south coefficients do not appear in the equation as their influence is integrated through the boundary conditions as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Element #2

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The south coefficient does not appear in the equation as its influence is integrated through the boundary conditions as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Element #3

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The east and south coefficients do not appear in the equation as their influence is integrated through the boundary conditions as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Element #4

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The west coefficient does not appear in the equation as its influence is integrated through the boundary condition as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Element #5

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

All coefficients appear in the equation as this is an internal element. The main coefficient and source term are calculated as

Substituting, the discretized algebraic equation is obtained as

Element #6

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The east coefficient does not appear in the equation as its represents a zero flux boundary condition. Moreover the main coefficient and source term are given by

Substituting, the discretized algebraic equation is obtained as

Element #7

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The west and north coefficients do not appear in the equation as their influence is integrated through the boundary conditions as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Element #8

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The north coefficient does not appear in the equation as its influence is integrated through the boundary condition as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Element #9

The needed diffusion terms are calculated as

The interface conductivities are

The general form of the equation is written as

where

The east and north coefficients do not appear in the equation as their influence is integrated through the boundary conditions as

The main coefficient and source term can now be calculated and are given by

Substituting, the discretized algebraic equation is obtained as

Summary of equations

The discretized algebraic equations are given by

Solution of Equations

To solve the above system of equations via the Gauss-Seidel method, the equations are rearranged into

The solution is found iteratively with the latest available values used during the solution process. Starting with a uniform initial guess of 300 K, Table 8.1 shows the results during the first two iterations along with the final converged solution.

Table 8.1

Summary of results obtained using the Gauss-Seidel iterative method

Iter

T l

T ₂

T ₃

T ₄

T ₅

T ₆

T ₇

T ₈

T ₉

0

300

300

300

300

300

300

300

300

300

1

308.000

300.083

300.098

308.000

300.037

300.048

306.859

300.031

300.045

2

309.633

300.131

300.146

309.428

300.078

300.094

307.072

300.071

300.090

⋮

…

…

…

…

…

…

…

…

…

Solution

312.490

305.254

305.254

311.944

305.154

305.154

308.867

305.054

305.054

Values of T along the bottom boundary

These can be calculated from the specified boundary condition, in this case a specified flux, as

Using the above equation, the temperatures are calculated as

Values of T along the right boundary

The above equation with the heat flux set to zero can be used to calculate the temperature along the zero flux boundary, leading to

The boundary temperatures are therefore given by

Values of T along the top boundary

Using Eq. (8.45) the temperature values along the top boundary are computed as

Total heat transfer along the left boundary

The total heat transfer along the west boundary is given by

Total heat transfer along the top boundary

Along the top boundary, the total heat transfer is computed as

Total heat transfer along the bottom boundary

Knowing the heat flux, the total amount of heat transfer is found as

Check for energy conservation

For conservation, the sum of heat entering and leaving the domain should be equal to zero. The sum is computed as

The slight deviation from zero is due to the use of a limited number of digits during computations.

8.5 Non-Cartesian Orthogonal Grids

Let us now consider the case of an orthogonal grid that is not oriented along the x and y axes. As shown in Fig. 8.8, such a grid can be obtained by rotating the Cartesian grid of Fig. 8.1 by some angle.

Fig. 8.8

Example of non-Cartesian orthogonal grids

The discretized equation for this grid should be exactly the same as the one obtained for the Cartesian grid. Moreover for similar boundary conditions, the same solution should be obtained.

Consider again the steady state conduction Eq. (8.1)

(8.58)

As before its discretized form is given by

(8.59)

Considering the discretization along face e, the following is obtained:

(8.60)

where now

(8.61)

is the gradient of ϕ at face e along the n direction. Assuming again a linear profile for ϕ along the n coordinate axis, the gradient can be written as

(8.62)

The discretization of other terms proceeds as for a Cartesian grid, leading to the same final discretization equation.

8.6 Non-orthogonal Unstructured Grid

8.6.1 Non-orthogonality

In the above configurations, the fluxes were normal to the face. In general, structured curvilinear grids and unstructured grids are non-orthogonal [2–5].Therefore the surface vector S f and the vector CF joining the centroids of the elements straddling the interface are not collinear (see Fig. 8.9). In this case the gradient normal to the surface cannot be written as a function of ϕ F and ϕ C , as it has a component in the direction perpendicular to CF.

Fig. 8.9

An element in a non-orthogonal mesh system

Thus while on orthogonal grids the gradient in the direction normal to the interface yields

(8.63)

because CF and n (the unit vector normal to the surface) are aligned, on non-orthogonal grids [6, 7], the gradient direction that yields an expression involving ϕ F and ϕ C will have to be along the line joining the two points C and F.

If e represents the unit vector along the direction defined by the line connecting nodes C and F then

(8.64)

Therefore, the gradient in the e direction can be written as

(8.65)

Thus to achieve the linearization of the flux in non-orthogonal grids, the surface vector S f should be written as the sum of two vectors E f and T f , i.e.,

(8.66)

with E f being in the CF direction to enable writing part of the diffusion flux as a function of the nodal values ϕ F and ϕ C such that

(8.67)

The first term on the right hand side of Eq. (8.67) represents a contribution similar to the contribution on orthogonal grids, i.e., involving ϕ F and ϕ C , while the second term on the right hand side is called cross-diffusion or non-orthogonal diffusion [8] and is due to the non-orthogonality of the grid. Different options for the decomposition of S f are available and are discussed next.

8.6.2 Minimum Correction Approach

As shown in Fig. 8.10, the decomposition of S f is done in such a way as to keep the non-orthogonal correction in Eq. (8.67) as small as possible, by making E f and T f orthogonal. As the non-orthogonality increases, the contribution to the diffusion flux from ϕ F and ϕ C decreases. In this case the vector E f is computed as

(8.68)

Fig. 8.10

Decomposing S f via the minimum correction approach

8.6.3 Orthogonal Correction Approach

This approach, schematically depicted in Fig. 8.11, keeps the contribution of the term involving ϕ F and ϕ C the same as on an orthogonal mesh irrespective of the degree of grid non-orthogonality. To achieve this, E f is defined as

(8.69)

Fig. 8.11

Decomposing S f via the orthogonal correction approach

8.6.4 Over-Relaxed Approach

In this approach, the importance of the term involving ϕ F and ϕ C is forced to increase as grid non-orthogonality increases. As shown in Fig. 8.12, this is achieved by selecting T f to be normal to S f . Mathematically E f is computed as

(8.70)

Fig. 8.12

Decomposing S f via the over-relaxed approach

To summarize, the diffusion flux at an element face of a non-orthogonal grid cannot be written solely in terms of the values at the nodes straddling the face. A term that accounts for non-orthogonality has to be added. This term is denoted in the literature by “cross diffusion” and is computed as

(8.71)

For orthogonal meshes n and e are collinear, the angle θ shown in Fig. 8.9 is zero, and the cross-diffusion term is zero. When cross diffusion is not zero, and since it cannot be written as a function of ϕ F and ϕ C , it is added as a source term in the element algebraic equation.

All approaches described above are correct and satisfy Eq. (8.59). The difference between these methods is in their accuracy and stability on non-orthogonal meshes. The over-relaxed approach has been found to be the most stable even when the grid is highly non-orthogonal. Nevertheless, the final general form of the discretized diffusion term is the same for all three approximations.

8.6.5 Treatment of the Cross-Diffusion Term

The cross diffusion term cannot be expressed in terms of nodal values. Due to this fact, it is treated in a deferred correction manner by computing its value using the current gradient field and adding it as a source term on the right hand side of the algebraic equation. Gradients are computed at the main grid points, as described next, and values at the interfaces are obtained by interpolation.

8.6.6 Gradient Computation

In discretizing the diffusion term over a one-dimensional or orthogonal multi-dimensional computational domain, it was shown that the gradient of ϕ can be explicitly written as a function of the cell nodal ϕ values. In non-orthogonal domains however, the computation of the diffusion flux was found to be more complex. The non-orthogonal component of the gradient could not be linearized and written as a function of nodal values, but rather had to be moved to the right hand side and evaluated explicitly. This means that the gradient has to be evaluated in order to incorporate its non-orthogonal contribution in the discretization equation. One widely used approach for computing the gradient at a cell is the Green-Gauss or gradient theorem, which states that for any closed volume V, surrounded by a surface ∂V the following holds:

(8.72)

where d S is the outward pointing incremental surface vector. In order to obtain a discrete version of this equation, the mean value theorem is applied according to which the integral on the left hand side of Eq. (8.72) and the average gradient over the volume V are related by

(8.73)

Combining Eqs. (8.72) and (8.73), the average gradient over element C shown in Fig. 8.9 is found to be

(8.74)

Next the integral over a cell face is approximated by the face centroid value times the face area. Thus $$ \overline{\nabla \phi }_{C} $$, or simply ∇ϕ C , is computed as

(8.75)

The gradient at the face of an element can then be obtained as the weighted average of the gradients at the centroids straddling the interface and is given by

(8.76)

where g C and g F are geometric interpolation factors related to the position of the element face f with respect to the nodes C and F.

8.6.7 Algebraic Equation for Non-orthogonal Meshes

Splitting the surface vector S f into the two E f and T f vectors and substituting its equivalent expression into the semi-discretized equation of the diffusion fluxes, yield

(8.77)

where again gDiff f is a geometric diffusion coefficient defined as

(8.78)

Using the above form of the diffusion fluxes and expanding, the final form of the discretized diffusion equation over unstructured/structured non-orthogonal grid is obtained as

(8.79)

where

(8.80)

Note the change in sign of the non-orthogonal term on the right hand side of the equation.

Example 2

For the polygonal element C and its neighbor F shown in Fig. 8.13 , the solution at any point satisfies ϕ = x ² + y ² + x ² y ² . If the volume of cell C is V C  = 8.625 calculate the following:

Fig. 8.13

A polygonal element with its geometric entities

1.

The gradient of ϕ at (i.e., ∇ϕ C ) both numerically and analytically.

2.

The analytical value of ∇ϕ F .

3.

Interpolate between the numerical value of ∇ϕ C and the analytical value of ∇ϕ F to find an approximate value for $$ \nabla \phi_{{f_{1} }} $$ . Compare with the analytical value of $$ \nabla \phi_{{f_{1} }} $$.

4.

Express $$ \nabla \phi_{{f_{1} }} $$ · $$ {\mathbf{S}}_{{f_{1} }} $$ in terms of ϕ C and ϕ F using

(a)

The minimum correction approach

(b)

The orthogonal correction approach

(c)

The over-relaxed approach

Solution

1. Knowing that ϕ = x ² + y ² + x ² y ² at any point in the domain, the value of the gradient at any point can be calculated as

Therefore the analytical value of ∇ϕ C is given by

The numerical value of ∇ϕ C can be computed using

Therefore the values of ϕ f and S f are required. Using the given analytical expression, the values of ϕ at the various locations are found as

The surface vector is given by

where the correct sign is chosen such that the vector is pointing outward. This is done by computing the surface vector as S f  = Δy i − Δx j and then performing the dot product of S f with the distance vector d CF (pointing from C to F). If the product is positive then the direction of S f is correct. If the product is negative then the sign of S f should be reversed, as shown below.

The distance vectors are computed as

while the tentative surface vectors are given by

Performing the dot products, the obtained values are

Therefore the correct values of the surface vectors should be

Thus, the numerical value of the gradient at C is obtained as

which is close to the analytical value.

2. The analytical value of ∇ϕ F is easily calculated as

3. The interpolated value of $$ \nabla \phi_{{f_{1} }} $$ is obtained using

where

Performing the calculations, the interpolation factor is found to be given by

leading to the following value for $$ \nabla \phi_{{f_{1} }} $$:

The analytical value of $$ \nabla \phi_{{f_{1} }} $$ is easily obtained as

Again values are close.

4. The general form of $$ \nabla \phi_{{f_{1} }} \cdot {\mathbf{S}}_{{f_{1} }} $$ is given by

with

The unit vector e ₁ in the direction of d CF is calculated using

(a) The minimum correction approach

Using this approach, the expression for $$ {\mathbf{E}}_{f_{1}} $$ is computed as

The normal component is computed as

The diffusion flux at the face becomes

(b) The orthogonal correction approach

In this approach, the expression for $$ {\mathbf{E}}_{f_{1}} $$ is computed as

The normal component is found to be

The diffusion flux at the face becomes

(c) The over-relaxed approach

The expression for $$ {\mathbf{E}}_{f_{1}} $$ is computed as

The normal component is found to be

The diffusion flux at the face becomes

8.6.8 Boundary Conditions for Non-orthogonal Grids

The treatment of boundary conditions for non-orthogonal grids is similar to that for orthogonal grids with some minor differences related to the non-orthogonal diffusion contribution. This is outlined next.

8.6.8.1 Dirichlet Boundary Condition

For the case of a Dirichlet boundary condition, i.e., when ϕ is specified by the user at the boundary as shown in Fig. 8.14, the boundary discretization proceeds as in orthogonal-grids. However, there is a need now to account for the cross-diffusion, which arises on boundary faces as on interior faces. This happens whenever the surface vector is not collinear with the vector joining the centroids of the element and boundary face. The diffusion flux along the boundary face is discretized as

(8.81)

where

(8.82)

Fig. 8.14

Dirichlet boundary for a non-orthogonal mesh

Substituting into Eq. (8.79), the modified coefficients are obtained as

(8.83)

8.6.8.2 Neumann Boundary Condition

The Neumann type condition for non-orthogonal grids follows that for orthogonal grids. In this case the user-specified flux at the boundary is just added as a source term as with orthogonal grid. The algebraic equation at the boundary is given by Eq. (8.40) with the modified coefficients specified by Eq. (8.41).

8.6.8.3 Mixed Boundary Condition

For the mixed boundary condition case (Fig. 8.5), denoting the convection transfer coefficient by h ∞ and the surrounding value of ϕ by $\phi_{\infty }$, the diffusion flux at the boundary can be written as

(8.84)

from which an equation for ϕ b is obtained as

(8.85)

Substituting ϕ b back in Eq. (8.84), the flux equation is transformed to

(8.86)

where now

(8.87)

and the modified coefficients for the boundary element are obtained as

(8.88)

8.7 Skewness

To evaluate many of the terms constituting the general discretized equation of a quantity ϕ, it is necessary to estimate its value at element faces. An estimated value at the face should be the average value of the entire face. At different steps of the discretization process, linear variation of variables between nodes is assumed. If this is extended to variation of variables along the face, then the average value of any variable ϕ should be found at the face centroid. The common practice is to use a linear interpolation profile and to estimate the value at the face at the intersection between the face and the line connecting the two nodes straddling the face. When the grid is skewed the line does not necessarily pass through the centroid of the face [9, 10]. An example is depicted in Fig. 8.15 where the intersection point of segment [CF] with the face is at point, f′, which does not coincide with the face centroid, f. To keep the overall accuracy of the discretization method second order, all face integrations need to take place at point f. Thus a correction for the interpolated value at f′ is needed in order to get the value at f.

Fig. 8.15

Non-conjunctional elements

The skewness correction is derived by expressing the value of ϕ at f in terms of its value and the value of its derivative at f′ via a Taylor expansion such that

(8.89)

where d f′f is a vector from the intersection point f′ to the face centre f.

8.8 Anisotropic Diffusion

The diffusion equation presented so far assumed the material has no preferred direction for transfer of ϕ with the same diffusion coefficient in all directions, i.e., the medium was assumed to be isotropic. For the case when the diffusion coefficient of the medium is direction dependent, diffusion is said to be anisotropic [11–16]. As mentioned in Chap. 3, some solids are anisotropic for which the semi-discretized diffusion equation becomes

(8.90)

where κ ϕ is a second order symmetric tensor. Assuming a general three dimensional situation, the term on the left hand side, through some mathematical manipulation [17], can be rewritten as

(8.91)

Performing matrix multiplication, Eq. (8.91) becomes

(8.92)

Further manipulations yield

(8.93)

Substituting Eq. (8.93) into Eq. (8.90), the new form of the diffusion equation becomes

(8.94)

It is obvious that in this form the discretization procedure described above can be applied by simply setting $$ \Gamma ^{\phi } $$ to 1 and replacing S f by $$ {\mathbf{S}}_{f}^{\prime } $$. Therefore the same code can be used to solve isotropic and anisotropic diffusion problems.

8.9 Under-Relaxation of the Iterative Solution Process

For a general diffusion problem, $$ \Gamma ^{\phi } $$ may be a function of the unknown dependent variable ϕ and the grid may be highly non-orthogonal with a large cross diffusion term, which is treated using a deferred correction approach. Therefore large variations in ϕ between iterations result in large source terms and large changes in the coefficients, which may cause divergence of the iterative solution procedure. This divergence is usually due to the non-linearity introduced by the coefficients and the cross-diffusion term, which makes the source term highly affected by the current solution field which is not yet converged. To promote convergence and stabilize the iterative solution process, slowing down the changes in ϕ between iterations is highly desirable and is enforced by a technique called under - relaxation. There are many ways of introducing under-relaxation. One of the practices will be described here, others in Chap. 14. Derivations will be performed on the general discretization equation of the form

(8.95)

Equation (8.95) can be written as

(8.96)

Let $$ \phi_{C}^{*} $$ represents the value of ϕ C from the previous iteration. If $$ \phi_{C}^{*} $$ is added to and subtracted from the right hand side, then Eq. (8.96) becomes

(8.97)

where the expression between the parentheses represents the change in ϕ C produced by the current iteration. This change can be modified by the introduction of a relaxation factor λ ϕ , such that

(8.98)

or

(8.99)

At first, it should be noted that at convergence ϕ C and $$ \phi_{C}^{*} $$ become equal independent of the value of relaxation factor used. This is indeed reflected by Eq. (8.98), which shows that the converged value ϕ C does satisfy the original equation (Eq. 8.95). This property should be satisfied by any relaxation scheme.

Depending on the value of the relaxation factor λ ϕ , the equation may be either under relaxed (i.e., 0 < λ ϕ  < 1) or over-relaxed (i.e., λ ϕ  > 1). In CFD applications, under relaxation is usually used. A value of λ ϕ close to 1 implies little under relaxation, while a value close to 0 produces heavy under relaxation effects with very small changes in ϕ C from iteration to iteration.

The optimum under relaxation factor is problem dependent and is not governed by any general rule. The factors affecting λ ϕ values include the type of problem solved, the size of the system of equation (i.e., number of grid points in the domain), the grid spacing and its expansion rate, and the adopted iterative method, among others. Usually, values of λ ϕ are assigned based on experience or from preliminary calculations. Moreover, it is not necessary to use the same under-relaxation value throughout the computational domain and values may vary from iteration to iteration.

Equation (8.99) can be recast into the form of Eq. (8.95), where now the central coefficient a c becomes

(8.100)

while the source term is added to produce a new term as

(8.101)

This method of relaxation plays an important role in stabilizing the solution of non-linear problems.

8.10 Computational Pointers

8.10.1 uFVM

In uFVM the implementation of the diffusion term discretization for interior faces is performed in function cfdAssembleDiffusionTermInterior, the core of which is shown in Listing 8.1.

Listing 8.1

Assembly of the diffusion term at interior faces

In the above, FLUXC1f and FLUXC2f are equivalent to FluxC f and FluxF f in the text and are the coefficients of the owner and neighbor element, respectively. Moreover, gamma_f and gDiff_f are arrays defined over all interior faces, and using the dot notation, the expression gamma_f.* gDiff_f returns an array containing the product of the respective elements of the gamma_f and gDiff_f arrays. The dot notation in Matlab® allows for efficient operations over arrays and for the writing of a clearer code and is used in uFVM whenever practical.

The non-orthogonal term is stored in the FLUXVf coefficient and is equal to gamma_f .* dot(grad_f(: , :)’,Tf( :, :)’)’ .The total flux passing through face f, FLUXTf , is assembled as in Eq. (8.15).

The diffusion term is setup in cfdProcessOpenFoamMesh.m and Listing 8.2 shows the computation of the gDiff coefficient.

Listing 8.2

Computing the geometric diffusion coefficient

The effects of boundary conditions on the equations of boundary elements should be accounted for and Listing 8.3 shows the assembly of the diffusion term at boundary faces for the case of a Dirichlet boundary condition type.

Listing 8.3

Assembly of the diffusion term at boundary faces for a Dirichlet Condition

The implementation of other boundary condition types can be reviewed in file cfdAssembleDiffusionTerm.m .

Once the linearized coefficients are computed for each of the interior and boundary faces, then assembly into the global (sparse) matrix can proceed. This approach is used for the discretization of all flux terms in uFVM and the assembly is performed in the cfdAssembleIntoGlobalMatrixFaceFluxes function. Listing 8.4 shows the assembly into the sparse LHS matrix and the RHS vector of the coefficients at interior faces.

Listing 8.4

Assembly into LHS spare matrix and RHS array

For each interior face the coefficients are assembled into both the owner and neighbor element equations. For the owner the coefficients are ( ac(iOwner), anb(iOwner)(iOwnerNeighbourCoef), and bc(iOwner) ), while for the neighbor the coefficients become: ac(iNeighbour), anb(iNeighbour)(iNeighbourOwnerCoef) , and bc(iNeighbour) ). The different signs used in the assembly of the two equations is due to the fact that the face surface vector is pointing into the neighbor cell and out of the owner cell.

8.10.2 OpenFOAM®

In OpenFOAM® [18] the diffusion term can be evaluated explicitly using “fvc::laplacian(gamma, phi)”or implicitly via “fvm::laplacian(gamma,phi)” namespaces and functions. The “fvc::laplacian(gamma,phi)” returns a field in which the laplacian of a generic field ϕ (phi) is evaluated at each cell. The field is added to the right hand side of the system of equations. The “fvm::laplacian(gamma,phi)” returns instead an fvMatrix of coefficients evaluated as per Eq. (8.19), which is added to the left hand side of the system of equations, in addition to a field containing the non-orthogonal terms that is added to the right hand side of the system. The definition of the laplacian operator is located in the directory “$FOAM_SRC/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme” in the files “gaussLaplacianScheme.C”, “gaussLaplacianScheme.H”, and “gaussLaplacianSchemes.C”.

The “fvm::laplacian” definition displayed in Listing 8.5

Listing 8.5

Calculation of the Laplacian operator

reads with the following additional functions (Listing 8.6):

Listing 8.6

Additional functions needed for the calculation of the Laplacian operator

It is worth noting that in OpenFOAM® the assembly takes place directly into the global coefficients, which as described earlier in Chaps. 5, 6, and 7 are stored in three arrays, namely fvm.upper() , fvm.lower() , and fvm.diag() . The main part of the discretization is defined in the fvmLaplacianUncorrected function, where Eq. (8.19) is evaluated by first defining an fvMatrix object and then filling its upper triangle by the extra diagonal coefficients (this approach relies on the fact that the Laplacian operator returns a symmetric matrix). The “ deltaCoeffs.internalField() ” represents the gDiff field while gamma indicates the diffusion field. The diagonal coefficients are evaluated in fvm.negSumDiag() ,where the negative sum of the upper and lower coefficients are assembled into the diagonal coefficients as per Eq. (8.18).

The “ fvm.negSumDiag() ” method is defined in lduMatrixOperations.C as (Listing 8.7)

Listing 8.7

Calculation of the negative sum of the upper and lower coefficients

The boundary conditions are implemented exactly as in Eqs. (8.36) and (8.41). In OpenFOAM® the boundary coefficients are stored in “ internalCoeffs ” (FluxC b ) and “ boundaryCoeffs ” (FluxV b ), already defined in Sect. 7.​6.

In “ fvmUncorrected ”only the orthogonal discretization is accounted for. The non-orthogonal contribution is added, as shown in Listing 8.8, using

Listing 8.8

Adding the nonorthogonal diffusion contribution

Again this term represents exactly the implementation of the last term of Eq. (8.77) in which the snGrad class wraps into the correction function the non-orthogonal term as shown below in Listing (8.9).

Listing 8.9

Implementation of the nonorthogonal term into the correction function

The non-orthogonal correction term is defined in the fullGradCorrection function where “mesh.nonOrthCorrectionVectors()” returns the T vector of Eq. (8.66).

The type of Laplacian discretization to be used is specified in the “fvSchemes” file, which is part of the case definition and is located in the system directory (Listing 8.10), in which Gauss (the only available choice) defines the standard Gauss discretization resulting in Eq. (8.18), linear refers to the type of interpolation used for calculating the diffusivity gamma at the face, and corrected describes the kind of non-orthogonal correction.

Listing 8.10

The discretization type for the Laplacian operator

More details on the implementation of boundary conditions in OpenFOAM® are presented in later chapters.

8.11 Closure

In this chapter the discretization of the diffusion equation was described. A number of issues were also addressed, such as the use of orthogonal and non-orthogonal grid systems, the implementation of boundary conditions, and under and over relaxation. The next chapter will concentrate on the calculation of the gradient field.

8.12 Exercises

Exercise I

Consider the diffusion of a property ϕ in the one-dimensional domain shown in Fig. 8.16 with no internal sources. The domain is subdivided into 5 uniform elements of size Δx = 1 and subject to a Dirichlet and a Neumann condition at boundary ‘0’ and ‘6’, respectively. The diffusion coefficient in the domain is constant with a value of 1, i.e., $$ {\Gamma}^{\phi } = 1 $$.

a.

Derive the discrete equation for each of the elements.

b.

Solve the system of equations using the Gauss-Seidel iterative method and report the resulting cell-centroid values.

c.

Compute the diffusion flux $$ \left( { - {\Gamma} d\phi /dx} \right) $$ at each of the cell faces and show that conservation is satisfied throughout the domain

d.

Compare your solution with the exact solution (Note that even though the computed solution is conservative, it is not exact).

e.

For the case where a zero flux boundary condition is defined at both boundaries ‘0’ and ‘6’, reformulate the equations for elements 1 and 5 and explain why the equations cannot be solved.

Fig. 8.16

Computational domain for a one dimensional diffusion problem with no internal sources

Exercise 2

A fin is exposed to the surrounding fluid at a temperature T a  = 25 °C, as shown in Fig. 8.17, with a heat transfer coefficient of h = 100 W/m² K and a thermal conductivity with value of k = 160 W/m K. The fin has a length L = 0.1 m, a cross sectional area A = 10⁻⁵ m², and a perimeter P = 0.1004 m.

Fig. 8.17

Computational domain for heat transfer from a fin

The temperature distribution in the fin is governed by the following differential equation

Discretize the above equation by subdividing the computational domain into 5 elements of equal size and find the values of the temperature field at the element centroids and boundaries in the following two situations:

a.

$$ T\left( {x = 0} \right) = 200\;^\circ {\text{C}} $$ and $$ T\left( {x = L} \right) = 90\;^\circ {\text{C}} $$

b.

$$ q\left( {x = 0} \right) = 20\;{\text{kW}}/{\text{m}}^{2} $$ and $$ q\left( {x = L} \right) = 10\;{\text{kW}}/{\text{m}}^{2} $$

where q is the rate of heat transfer given by

Exercise 3

The heat conduction in the two-dimensional domain shown in Fig. 8.18 is governed by the following differential equation:

Fig. 8.18

Heat conduction in a two dimensional tilted Cartesian domain

The domain is subdivided into uniform elements and the boundary conditions are as shown in the figure.

a.

Derive the algebraic equations for all elements.

b.

Solve the system of equations obtained and compute the T values at the centroids of the elements.

c.

Compute the values of T at the bottom and right boundaries.

d.

Compute the net heat transfer through the top and left boundaries

Exercise 4

Consider steady state conduction heat transfer in the non-orthogonal domain discretized into the four equal elements shown in Fig. 8.19, where L = 1 m. Derive the discretization equations for the cells using two different methods for the decomposition of the diffusion flux and compare the temperature values at the element centroids after 4 coefficient iterations.

Fig. 8.19

Computational domain for Exercise 4

Exercise 5

Discretize the equation −∇ · k∇T = Q T where Q T  = 500 and k = 200, for the mesh composed of quadrilateral triangles of side 0.1 shown in Fig. 8.20. Write the discretized equations in the form of general algebraic equations.

Fig. 8.20

A triangular domain covered with an unstructured grid system

Exercise 6

The gradient for a variable ϕ over the computational domain shown in Fig. 8.21 is given by

Fig. 8.21

A rectangular domain decomposed into two triangular elements

Compute the value of ϕ at nodes 1 and 2 given that the length and width of the computational domain are 10 and 5 cm, respectively.

Exercise 7

Using the mesh constructed in exercise 3 of Chap. 7 (displayed in Fig. 7.​12), setup a case in OpenFOAM® and uFVM to solve the diffusion equation subject to the following conditions $$ ({\Gamma}^{\phi } = 1) $$:

Patch#1

ϕ = 1

Patch#2

ϕ = 0

Patch#3

∇ϕ · n = 0

Patch#4

h ∞ = 1, ϕ ∞ = 0.5

Exercise 8

Build an oblique parallelogram (size of horizontal side is 1 and size of oblique side is 2 inclined at 60 degrees with respect to the horizontal) using blockMesh in OpenFOAM® with the boundary conditions shown in the figure below to solve the diffusion equation with no source term in two dimensions. Generate a grid by decomposing each side of the parallelogram into 50 equal segments. Setup the case and using a diffusion coefficient of 1 compare the convergence history for the three different approaches mentioned in this chapter to resolve the non-orthogonal term for the diffusion equation (one at a time) in uFVM and in OpenFOAM®. Use an under-relaxation factor of value 0.9 (Fig. 8.22).

Fig. 8.22

An oblique parallelogram

Exercise 9

a.

Use Doxygen [19] to find the list of all overloaded functions under the name fvmLaplacian and then under then name fvcLaplacian.

b.

Define in the dictionary file fvSchemes the option to exclude the non orthogonal correction (Gauss linear uncorrected;).

c.

Define in the dictionary file fvSchemes the option to use a limited non orthogonal correction (Gauss linear limited 0.8;).

d.

List of the possible Laplacian non orthogonal correction type available in OpenFOAM® (Hint: just mistype a scheme, i.e., banana, and launch any solver or application).

References

1.

Patankar SV (1980) Numerical heat transfer and fluid flow. Hemisphere Publishing Corporation, McGraw-Hill, USAMATH

2.

Jiang T, Przekwas AJ (1994) Implicit, pressure-based incompressible Navier-stokes equations solver for unstructured meshes. AIAA-94-0305

3.

Davidson L (1996) A pressure correction method for unstructured meshes with arbitrary control volumes. Int J Numer Meth Fluids 22:265–281MATHCrossRef

4.

Barth TJ (1992) Aspects of unstructured grids and finite-volume solvers for the Euler and Navier-stokes equations. Special course on unstructured grid methods for advection dominated flows. AGARD Report 787

5.

Perez-Segarra CD, Farre C, Cadafalch J, Oliva A (2006) Analysis of different numerical schemes for the resolution of convection-diffusion equations using finite-volume methods on three-dimensional unstructured grids, Part I: discretization schemes. Numer Heat Transfer Part B: Fundam 49(4):333–350CrossRef

6.

Demirdzic I, Lilek Z, Peric M (1990) Finite volume method for prediction of fluid flow in arbitrary shaped domains with moving boundary. Int J Numer Meth Fluids 10:771–790MATHCrossRef

7.

Demirdzic I, Lilek Z, Peric M (1993) A collocated finite volume method for predicting flows at all speeds. Int J Numer Meth Fluids 16:1029–1050MATHCrossRef

8.

Warsi ZUA (1993) Fluid dynamics: theoretical and computational approaches. CRC Press, Boca RatonMATH

9.

Berend FD, van Wachem GM (2014) Compressive VOF method with skewness correction to capture sharp interfaces on arbitrary meshes. J Comput Phys 279:127–144MathSciNetCrossRef

10.

Jasak H (1996) Error analysis and estimation for the finite volume method with applications to fluid flow. Ph.D. thesis, Imperial College London

11.

Balckwell BF, Hogan RE (1993) Numerical solution of axisymmetric heat conduction problems using the finite control volume technique. J Thermophys Heat Transfer 7:462–471CrossRef

12.

Wang S (2002) Solving convection-dominated anisotropic diffusion equations by an exponentially fitted finite volume method. Comput Math Appl 44:1249–1265MATHMathSciNetCrossRef

13.

Jayantha PA, Turner IW (2003) On the use of surface interpolation techniques in generalised finite volume strategies for simulating transport in highly anisotropic porous media. J Comput Appl Math 152:199–216MATHMathSciNetCrossRef

14.

Bertolazzi E, Manzini G (2006) A second-order maximum principle preserving finite volume method for steady convection-diffusion problems. SIAM J Numer Anal 43:2172–2199MathSciNetCrossRef

15.

Domelevo K, Omnes P (2005) A finite volume method for the Laplace equation on almost arbitrary two-dimensional grids. Math Model Numer Anal 39:1203–1249MATHMathSciNetCrossRef

16.

Eymard E, Gallouet T, Herbin R (2004) A finite volume scheme for anisotropic diffusion problems. Comptes Rendus Mathematiques (CR MATH) 339:299–302MATHMathSciNetCrossRef

17.

Darwish M, Moukalled F (2009) A compact procedure for discretization of the anisotropic diffusion operator. Numer Heat Transfer, Part B 55:339–360CrossRef

18.

OpenFOAM, 2015 Version 2.3.x. http://​www.​openfoam.​org

19.

OpenFOAM Doxygen, 2015 Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_9

9. Gradient Computation

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

As was shown in the previous chapter, the discretization of the gradients of $$ \phi $$ at cell centroids and faces is fundamental to constructing the discretized sets of diffusion equations and, as will be revealed in later chapters, of equations involving the convection term. In addition, the evaluation of gradients is needed for the evaluation of various operators. For example, pressure derivatives are directly needed in the discretized momentum equations, while velocity gradients are required to compute the production term in turbulence models, and the strain rate in non-Newtonian viscosity models. This chapter describes several techniques for evaluating gradients on a general mesh topology. The chapter starts with a description of the techniques for computing the gradient on cartesian structured grids and proceeds with gradient evaluation on unstructured grids. The presented methods follow either the Green-Gauss or the least square approach. Methods to interpolate the gradient to element faces are also presented.

9.1 Computing Gradients in Cartesian Grids

For the one-dimensional problem shown in Fig. 9.1 discretized using a uniform grid, a linear profile assumption for the variation of $$ \phi $$ between cell centroids results in the following expression for the derivative at cell face e:

(9.1)

Fig. 9.1

Computing the gradient on a uniform one dimensional grid

In the same way, the derivative at the cell centroid C (Fig. 9.1) can be written using the values at the two adjacent cells as

(9.2)

This expression is usually referred to as the “central difference” approximation of the first derivative.

For Cartesian grids in multiple dimensions, the derivatives can be computed by applying the same principle along the respective coordinate directions. Consider, for example, the two dimensional grid shown in Fig. 9.2, using the central difference approximation introduced earlier, the partial derivatives in the x and y directions are obtained as

(9.3)

Fig. 9.2

Computing the gradient on a two dimensional Cartesian grid

A similar equation holds in the z direction for three dimensional grids.

When dealing with unstructured grids the computation of the gradient using the above method becomes unpractical and leads to the use of more general methods, some of these are now presented.

9.2 Green-Gauss Gradient

This is one of the most widely used methods for computing the gradient. It was introduced in the previous chapter and will not be repeated here. Rather the final form of the equation will be given and some additional methods to compute the face values will be introduced.

As derived in the previous chapter, the gradient at the centroid of an element C with volume V C ( Fig. 8.​8) is computed as

(9.4)

where f refers to a face and S f to its surface vector. The face values $$ \phi_{f} $$ still need to be defined before the formula can be used. Two approaches are presented for computing $$ \phi_{f} $$. One is face-based with a generally compact stencil involving face neighbors, and the second is vertex-based with a larger stencil involving vertex neighbors. The number of cells in this extended stencil is about twice the compact one.

The use of a compact stencil is attractive with implicit methods because it leads to more compact Jacobian matrices. However, the enlarged stencil brings more information into the reconstruction, and is therefore expected to be more accurate.

Method 1: Compact Stencil [1]

For the two and three dimensional grid system shown in Fig. 9.3a, b, respectively, a simple approximation for calculating $$ \phi_{f} $$ is to use the average values of the two cells sharing the face. In this case the value of $$ \phi_{f} $$ is calculated as

(9.5)

where g C is a geometric weighting factor equal to

(9.6)

where r designates the position vector and d the distance between two points. When the face is situated halfway between the two cell centers, $$ \phi_{f} $$ is found to be

(9.7)

Fig. 9.3

Conjunctional face in a a two dimensional and b a three dimensional configuration; non-conjunctional face in c a two dimensional and d a three dimensional configuration

This approach is simple to implement in two and three dimensional situations and all operations involved are face-based, not requiring any additional grid connectivity. Accuracy-wise, the above relation leads to a second order approximation of $$ \phi_{f} $$ only when the segment [CF] and face S f intersection point coincides with the centroid of the face S f , i.e., with the Gaussian integration point f. Thus a second order accurate representation of the gradient is generally not achieved except for the above special case.

Such a condition is not usually satisfied with a general structured non-orthogonal or unstructured grid systems as shown for the two and three dimensional grid systems displayed in Fig. 9.3c, d, respectively. Rather, the skewness of the mesh (non-conjunctionality) results in the segment [CF] and the surface $$ S_{f} $$ intersecting at a point $$ f' $$, different from the face centroid f. In this case a correction is needed for the interpolated $$ \phi_{f'} $$ value to get $$ \phi_{f} $$. The correction equation is given by

(9.8)

which may also be written in expanded form as

(9.9)

Since g C depends on $$ f^{\prime} $$, Eq. (9.9) indicates that improved estimates of the gradient can be obtained iteratively. At each iteration, the average value at the face is computed using the gradients calculated in the pervious iteration. These face values are then used to compute new estimates of the gradients. Doing excessive number of iterations may cause oscillations and usually not more than two iterations are performed.

In this case, the calculation of g C requires locating the intersection point $$ f^{\prime} $$ between [CF] and the face S f . For that purpose three options will be described.

Option 1:

In this option $$ f^{\prime} $$ is taken to be the exact intersection between [CF] and the face S f of surface vector S f . With n denoting the surface unit vector (i.e., $$ {\mathbf{n}} = {\mathbf{S}}_{f} /\left\| {{\mathbf{S}}_{f} } \right\| $$) and e the unit vector along CF (i.e., $$ {\mathbf{e}} = {\mathbf{CF}}/\left\| {{\mathbf{CF}}} \right\| $$), the location of $$ f^{\prime} $$ (Fig. 9.3c, d) can be found by exploiting the orthogonality condition that exists between n and the segment $$ ff^{\prime} $$ (i.e., n is normal to the face S f containing the segment $$ ff^{\prime} $$) to write

(9.10)

Further, since $$ f^{\prime} $$ is a point on CF the vector $$ \varvec{Cf^{\prime}} $$ can be expressed in terms of e as

(9.11)

where k is a scalar quantity. Combining Eqs. (9.10) and (9.11) yields

(9.12)

with $$ f^{\prime} $$ located, g C is computed as

(9.13)

Then, the calculation procedure involves the following steps:

During the first iteration, calculate the gradient field over the entire domain as follows:

1.

Calculate $$ \phi_{f^{\prime}} $$ using $$ \phi_{f'} = g_{C} \phi_{C} + \left( {1 - g_{C} } \right)\phi_{F} $$

2.

Calculate $$ \nabla \phi_{C} $$ using $$ \nabla \phi_{C} = \frac{1}{{V_{C} }}\sum\limits_{f{\sim}nb(C)} {\phi_{f'} {\mathbf{S}}_{f} } $$

From the second iteration onward, correct the gradient field according to the following procedure:

3.

Update $$ \phi_{f} $$ using

4.

Update $$ \nabla \phi_{C} $$ using $$ \nabla \phi_{C} = \frac{1}{{V_{C} }}\sum\limits_{f{\sim}nb(C)} {\phi_{f} {\mathbf{S}}_{f} } $$

5.

Go back to step 3 and repeat.

Option 2:

For $$ f^{\prime} $$ chosen to be at the centre of segment [CF] [Fig. 9.4a in two dimensions and Fig. 9.4b in three dimensions] the equations become simpler and the calculation of the gradient field over the domain proceeds as follows:

Fig. 9.4

Correction to Non-Conjunctionality using the midpoint approach: a two dimensional configuration; b three dimensional configuration

During the first iteration, calculate the gradient field over the entire domain as follows:

1.

Calculate $$ \phi_{{f^{\prime}}} $$ ’ using $$ \phi_{f'} = \frac{{\phi_{C} + \phi_{F} }}{2} $$

2.

Calculate $$ \nabla_{{\phi_{C} }} $$ using $$ \nabla \phi_{C} = \frac{1}{{V_{C} }}\sum\limits_{f{\sim}nb(C)} {\phi_{f'} {\mathbf{S}}_{f} } $$

From the second iteration onward, correct the gradient field according to the following procedure:

3.

Update $$ \phi_{f} $$ using

4.

Update $$ \nabla \phi_{{{C}}} $$ using $$ \nabla \phi_{C} = \frac{1}{{V_{C} }}\sum\limits_{f{\sim}nb(C)} {\phi_{f} {\mathbf{S}}_{f} } $$

5.

Go back to step 3 and repeat

Option 3:

The position of $$ f^{\prime} $$ can be chosen such that the distance $$ ff^{\prime} $$ is the shortest possible [Fig. 9.5a in two dimensions and Fig. 9.5b in three dimensions], i.e., $$ \left[ {ff^{\prime}} \right] $$ perpendicular to [CF]. This leads to a more accurate computation of the gradient during the first iteration. In this case $$ f^{\prime} $$ is computed by minimizing the distance between f and $$ f^{\prime} $$. In general $$ {\mathbf{r}}_{{f^{\prime}}} $$ is described by

(9.14)

where 0 < q < 1.

Fig. 9.5

Correction to Non-Conjunctionality using the minimum distance approach: a two dimensional configuration; b three dimensional configuration

Denoting the distance $$ f^{\prime}f $$ by d, then its square is obtained as

(9.15)

Minimizing the function d ² with respect to q, yields

(9.16)

Solving, q is obtained as

(9.17)

Knowing the q values, the gradient calculation over the domain proceeds as follows:

During the first iteration, calculate the gradient field over the entire domain as follows:

1.

Calculate $$ {\mathbf{r}}_{{f^{\prime}}} $$ using

2.

Calculate g C using $$ g_{C} = \left\| {{\mathbf{r}}_{F} - {\mathbf{r}}_{f'} } \right\|/\left\| {{\mathbf{r}}_{F} - {\mathbf{r}}_{C} } \right\| $$

3.

Calculate $$ \phi_{{f^{\prime}}} $$ using $$ \phi_{f'} = g_{C} \phi_{C} + \left( {1 - g_{C} } \right)\phi_{F} $$

4.

Calculate $$ \nabla \phi_{C} $$ using $$ \nabla \phi_{C} = \frac{1}{{V_{C} }}\sum\limits_{f{\sim}nb(C)} {\phi_{f'} {\mathbf{S}}_{f} } $$

From the second iteration onward, correct the gradient field according to the following procedure:

5.

Calculate $$ \nabla \phi_{{f^{\prime}}} $$ using $$ \nabla \phi_{f'} = g_{C} \nabla \phi_{C} + \left( {1 - g_{C} } \right)\nabla \phi_{F} $$

6.

Update $$ \phi_{f} $$ using $$ \phi_{f} = \phi_{f'} + \nabla \phi_{f'} \cdot \left( {{\mathbf{r}}_{f} - {\mathbf{r}}_{f'} } \right) $$

7.

Update $$ \nabla \phi_{C} $$ using $$ \nabla \phi_{C} = \frac{1}{{V_{C} }}\sum\limits_{f{\sim}nb(C)} {\phi_{f} {\mathbf{S}}_{f} } $$

8.

Go back to step 5 and repeat

Example 1

For the mesh shown in Fig. 9.6 , the coordinates of the grid point C and its neighbors F 1 through F 6 are given by

Fig. 9.6

Grid layout for Examples 1 and 2

while the nodes n₁ through n₆ are located at

If the values of the dependent variable $$ \phi $$ at the centroids are known to be

and the values of the gradient of $$ \phi $$, $$ \left( {\nabla \phi } \right) $$ , at all neighboring elements to C are given by

If the volume of cell C is V C  = 76, find the gradient $$ \nabla \phi_{C} $$ using

a.

The Green-Gauss method with no correction

b.

The Green-Gauss method alongside correction to skewness with $$ f^{\prime} $$ chosen to be at the centre of segment [CF].

Solution The Green-Gauss method with no correction

a.

The interpolation factors are needed to perform the calculations. This, in turn, necessitates computing the coordinates of the face centroids. The coordinates of the centroid f ₁ are found as

In a similar way, the coordinates of other face centroids are found to be

The surface vectors are calculated as

The interpolation factor (g C )₁ is computed using

In a similar way, the other interpolation factors are found to be

Using Eq. (9.5) the $$ \phi_{f} $$ values are computed as

Using Eq. (9.4), $$ \nabla \phi_{C} $$ is calculated as

b.

The Green-Gauss method alongside correction to skewness with $$ f^{\prime} $$ chosen to be at the centre of segment [CF].

The values at the $$ f^{\prime} $$ locations are computed as half the sum of the values at the nodes straddling the face and are given by

Using these values, the first estimate for the gradient is obtained using Eq. (9.4) as

Defining d f  = r f  − 0.5 × (r C  + r F ), the various values are found to be

Using $$ \phi_{f} = \phi_{{f^{\prime}}} + \, 0. 5 { }*[(\nabla \phi )_{C} + \, (\nabla \phi )_{F} ]\cdot\left[ {{\mathbf{r}}_{f} - 0. 5*\left( {{\mathbf{r}}_{C} + {\mathbf{r}}_{F} } \right)} \right] $$ the updated values at the faces are obtained as

These values are used in Eq. (9.4) yielding the updated value of the gradient as

Method 2: Extended Stencil [2]

The value of $$ \phi_f $$ at the surface centroid f can be computed as the mean of the values at the vertices defining the surface. This necessitates the estimation of the properties at the vertices. The properties at a vertex node are calculated using the weighted average of the properties within the cells surrounding that node. Figure 9.7 shows the cells that are considered for the weighted average of the properties at the vertex nodes n ₁ and n ₂. The weight is taken as the inverse of the distance of the vertex from the cell centre [3]. The resulting equation for the properties at the vertices are written as,

(9.18)

where n refers to the vertex node, F k to the neighboring cell node, NB(n) the total number of cell nodes surrounding the vertex node n, and $$ \left\| {{\mathbf{r}}_{n} - {\mathbf{r}}_{{F_{k} }} } \right\| $$ the distance from the vertex node to the centroid of the neighboring cells.

Fig. 9.7

Cells Contributing to node n for the Weighted Average

Once the values $$ \phi_{n} $$ at the vertices are found, the values $$ \phi_{f} $$ at the surface centroids are calculated followed by the gradients at the control volume centroids. In two dimensional situations, $$ \phi_{f} $$ is computed as

(9.19)

Then the gradient at C is found using

(9.20)

In three dimensional situations, the calculations are a little more involved as the number of a face vertices depends on the element type. The value of $$ \phi_{f} $$ is found from the values at the vertices using

(9.21)

where n represents the number of vertices of face f. Once the values $$ \phi_{f} $$ are calculated, the gradient at C is computed using Eq. (9.4).

One of the disadvantages of this approach is that information from the wrong side of the cell face also contributes to the weighted average values of the conserved variables. This can be overcome by using upwind biased gradients as discussed by Cabello [4]. The higher order calculations based on the upwind biased gradients, however, have both higher memory overheads required to store the information about the cells used for the upwind biased gradient calculation and increased coding complexity.

Example 2

Using the data of example I, calculate $$ \phi_{{f_{1} }} $$ using the extended stencil approach via Eq. (9.16).

Solution

First the distances have to be calculated and are given by

The values at nodes n ₁ and n ₂ are computed using Eq. (9.15) as

The value of $$ \phi_{{f_{1} }} $$ is found to be

9.3 Least-Square Gradient

Using least-square methods to compute the gradients [5] offers more flexibility with regard to the order of accuracy achieved [6] and the stencil used [7]. In the least-square method, the divergence-based gradient can be recovered as a special case. This flexibility comes at a cost, as proper weighting is needed for the stencil terms, and computation of the weights adds to the computational cost. The method is described next.

Considering a control volume and its immediate neighbors (Fig. 9.8), the change in centroid values between C and F is given by $$ (\phi_{F} - \phi_{C} ) $$, if the cell gradient ($$ \nabla \phi_{C} $$) is exact, then the difference can also be computed as

(9.22)

Fig. 9.8

A control volume with its immediate neighbors

However unless the solution field is linear the cell gradient cannot be exact because C has more neighbors than the gradient vector has components. In the least square methods, a gradient is computed by an optimization procedure that finds the minimum of the function G C defined as

(9.23)

where w k is some weighting factor. The various terms in the above equation represent

(9.24)

The function G C is minimized by enforcing the conditions

(9.25)

to yield the following set of three equations in three unknowns:

(9.26)

which can be written in matrix form as

(9.27)

The solution to the above set of equations yields the gradient $$ \left( {\nabla \phi } \right)_{C} $$. A solution exists provided that the matrix on the left hand side is not singular. Moreover, the choice of the w k is important in determining the properties of the gradient. For example if w k is chosen to be 1 for all neighbors of C, then all neighboring points will have the same weight in the computation of the gradient irrespective of whether they are near or far from point C. Actually points that are farther from C will have a more important influence as the error function will be more affected by their error.

Another choice for w k , which was used earlier with the extended stencil method, is the inverse distance between C and F given by

(9.28)

Other options that can be pursued include the inverse distance raised to any power n such that

(9.29)

where n can be set to 1, 2, 3, etc.

As mentioned above, the divergence based gradient is a special case of the least-square formulation. This can be shown for a Cartesian grid (see Fig. 9.9) where substituting the geometric quantities into Eq. (9.27) would yield the following set of three equations.

Fig. 9.9

A three dimensional Cartesian control volume

(9.30)

Solving the above equation, the derivatives in the various directions are found to be

(9.31)

The obtained values are exactly the ones given in Eq. (9.3), demonstrating that the divergence-based gradient is a special case of the least-square method. Finally it can easily be demonstrated that the accuracy of the resulting gradient is at least first order. Indeed, the Taylor series expansion of the $$ \phi $$ value around node C can be written as

(9.32)

which when solved for $$ \left( {\nabla \phi } \right)_{C} $$ results in O(r).

9.4 Interpolating Gradients to Faces

It was shown in Chap. 8 that the discretization of the diffusion term in non-orthogonal grids requires the use of correction terms involving gradients at control volume faces. Thus in this situation the gradients need to be interpolated from the control volume centroids where they were computed to the control volume faces where they will be used. Figure 9.10a shows the stencil used in the Gauss gradient computation for two neighboring control volumes. The gradient at the face will have exactly the same stencil, while ideally it should be similar to that of Fig. 9.10b.

Fig. 9.10

a Interpolated and b corrected gradient at a control volume face

A better insight is gained by considering the configuration in Fig. 9.11a, which shows the gradients $$ \nabla \phi_{C} $$ and $$ \nabla \phi_{F} $$ of the variable $$ \phi $$ at the two nodes C and F, respectively. The interpolated gradient at the face, $$ \overline{\nabla \phi }_{f} $$, is obtained by averaging the values at nodes C and F, as shown in Fig. 9.11b. It is important for the stencil of the gradient at the face to be heavily based on the nodes straddling the face, which is not guaranteed by this simple averaging practice. As schematically displayed in Fig. 9.11c, this can be accomplished by forcing the face gradient along the CF direction to be equal to the local gradient defined by the values of $$ \phi $$ at C and F. Mathematically this can be written as

(9.33)

where

(9.34)

where r F and r C are position vectors, as displayed in Fig. 9.3. This approach is applicable to both structured and unstructured grids. For unstructured grids, while the stencil used for the face gradient might not be decreased, the gradient across a face will still be based on the nodes straddling that face.

Fig. 9.11

a Schematics of the gradients at the two nodes C and F straddling face f; b computing $$ \overline{\nabla \phi }_{f} $$ as a simple average of $$ \nabla \phi_{C} $$ and $$ \nabla \phi_{F} $$ using Eq. (9.31); c the gradient at the face with its value heavily based on the nodes straddling the face

9.5 Computational Pointers

9.5.1 uFVM

In uFVM, the functions cfdComputeGradientGauss0 and cfdComputeGradientNodal are used to compute the element gradients. The Gauss gradient routine (Listing 9.1) takes as input the phi element array and returns the element gradient array. The values are interpolated to the faces using a weighted factor with no correction for non-conjunctionality, hence the 0 digit in the function name.

Listing 9.1

Function used in uFVM to compute the gradient field at the centroids of elements following the Green-Gauss approach with phi values at the face computed using simple a weighted average interpolation technique with no correction to non-conjunctionality

The nodal gradient routine, listed below (Listing 9.2), is very similar to the Gauss gradient routine except that it uses the functions cfdInterpolateFromElementsToNodes and cfdInterpolateFromNodesToFaces to interpolate phi values to the face that are subsequently used in the Gauss algorithm.

Listing 9.2

Function used in uFVM to compute the gradient field at the centroids of elements following the Green-Gauss approach with phi values at the face computed using nodal values, i.e., the extended stencil approach

For face interpolation of gradients, a variety of interpolation options are allowed in the function cfdInterpolateGradientsFromElementsToInteriorFaces. The input to the function is theInterpolationScheme, the element gradient grad, the element array phi and mdot for cases where an upwind or downwind scheme is used. The function is shown in Listing 9.3.

Listing 9.3

Function used to interpolation the element gradient field to the faces

It should be noted that theInterpolationScheme “Average:Corrected” implements the face gradient correction technique used to get a more accurate gradient representation along the CF direction, i.e., Eq. (9.33).

9.5.2 OpenFOAM®

In OpenFOAM® [8] several types of gradient evaluation techniques are defined: the standard Green-Gauss method, the second order least square method, and the fourth order least square method. Attention will be focussed here on the Green-Gauss method. Nonetheless the discretization in all cases is performed explicitly and is thus part of the fvc operator namespace. The Green-Gauss gradient is defined at the cell centre, as in Eq. (9.4), and its source code in OpenFOAM is located in the directory “src/finiteVolume/finiteVolume/gradSchemes/gaussGrad”.

Implementation-wise, the gradient evaluation is performed in the following two steps:

Face interpolation of the variable

Green-Gauss formula evaluation

The interpolation to the face is in the calcGrad routine listed below (Listing 9.4).

Listing 9.4

Script to interpolate variable values to cell faces

As a first step, values are interpolated to the faces and stored in the generic field “vsf” (the interpolation class will be described with more details in Chap. 11). Then the gradient is computed based on the Green-Gauss formula in the gradf routine shown in Listing 9.5

Listing 9.5

Routine used to compute the gradient using the Green-Gauss method

.

The sum over cell faces is performed using the LDU addressing. As such the “for” loop that evaluates the sum over the faces of the cell is based only on the global face numbering and uses the upper and lower addressing vectors to add or subtract (Listing 9.6) the flux to cell values. After all fluxes have been processed, the net value is divided by the volume to yield the gradient, as in Eq. 9.4.

Listing 9.6

Adding or subtracting fluxes to cell values

The type of gradient is defined in fvSchemes shown in Listing 9.7.

Listing 9.7

Defining the gradient calculation method

The face interpolation scheme is defined as displayed in Listing 9.8.

Listing 9.8

Defining the interpolation method used in calculating face values

The idea of evaluating the gradient based on a generic interpolation scheme that has to be defined by dictionary, allows computing the gradient with the Green-Gauss formula in several ways by just changing the interpolation scheme.

If skew correction, as defined in Eq. (9.8), is required then the above interpolation scheme definition should be replaced by (Listing 9.9)

Listing 9.9

Defining the interpolation scheme to calculate face values with skew correction

A more compact syntax can be used for defining the gradient in which the interpolation type is specified directly under gradSchemes shown in Listing 9.10.

Listing 9.10

Defining the gradient calculation method: compact syntax

In this case the interpolation method is defined directly in the gradient dictionary. The choice of the syntax type is up to the user keeping in mind that a separate definition of the interpolation scheme helps clarifying the various steps of the gradient calculation.

9.6 Closure

This chapter presented the discretization details of two methods for computing the gradient at the centroids of control volume meshes in general non-orthogonal grid systems. One method is based on the Green-Gauss theorem and the second on the Least-Square reconstruction approach. Chapter 10 will be devoted to methods used for solving systems of algebraic equations.

9.7 Exercises

Exercise 1

In the configuration depicted in Fig. 9.22, the values of the variable $$ \phi $$ and its gradient $$ \nabla \phi $$ at C are known. Using these known values estimate the value of $$ \phi $$ at F.

Fig. 9.22

A two dimensional element of centroid C and neighbor F

Exercise 2

For the two cells shown in Fig. 9.23 the value of some scalar ϕ at their centroids C and F can be calculated from

Fig. 9.23

Two elements in a two dimensional plane with their centroids C and F

The gradient at C and F are also computed to be the exact gradient of the function at these points such that

With C and F located at (0.32, −0.1) and (0.52, 0.31), respectively, find the value of the gradient at face f (0.43, 0.1) numerically (not from the expression for the gradient) using

a.

A simple averaging between C and F.

b.

A corrected averaging between C and F.

c.

Compare the two computed values with the exact gradient at point f.

Exercise 3

Consider the mesh composed of equilateral triangular elements shown in Fig. 9.24. The coordinates of the mesh vertices are as shown. The temperatures at the cell centroids are given by

a.

Compute the gradient at 1 using the Green-Gauss method.

b.

Compute the gradient at 1 using the least squares approach with a limited stencil (i.e., nodes 2, 3 and 4) and with an extended stencil (i.e., nodes 2–13) used for the reconstruction.

c.

Compare the least squares gradient with the limited and extended stencil and the gauss gradient to the exact gradient.

Fig. 9.24

A domain discretized using triangular elements

Exercise 4

Consider the uniform mesh shown in Fig. 9.25. The coordinates of the mesh vertices are as shown. The temperatures at the cell nodes are given by

compute the gradient at the centroid of cell 1 using the gauss gradient with and without face corrections and compare to the exact gradient given by

Fig. 9.25

Mesh system for Exercise 4

Exercise 5 (uFVM, OpenFOAM®)

Using uFVM and then OpenFOAM® write a program that

a.

reads an OpenFOAM® mesh and sets a scalar field with values equal to $$ \phi \left( {x,y,z} \right) = 10x^{2} y^{2} + 3y $$

b.

computes the gradients using the second order least square method,

c.

computes the gradients using the gauss gradient method with linear interpolation,

d.

computes the gradients using the gauss gradient method with vertex interpolation,

e.

and computes the root mean square error between each of the computed gradients and the exact gradient.

Exercise 6 (uFVM, OpenFOAM®)

Using uFVM and then OpenFOAM® write a program that

a.

reads an OpenFOAM® mesh and sets a scalar field with values equal to $$ \phi \left( {x,y,z} \right) \, = { 1}0x^{ 2} y^{ 2} + { 3}y $$

Use the exact gradients at the element nodes to compute the gradients at the interior faces using

b.

simple linear interpolation,

c.

corrected linear interpolation,

d.

and exact gradient formulation at the face centroids.

e.

Compute the root mean square error between each of the computed gradients and the exact gradient.

Exercise 7

Starting with Eq. (9.8) derive Eq. (9.9).

Hint: $$ {\mathbf{r}}_{f} - {\mathbf{r}}_{{f^{\prime } }} = {\mathbf{r}}_{f} {-}{\mathbf{r}}_{C} - {\mathbf{r}}_{{cf^{\prime } }} = {\mathbf{r}}_{f} {-}{\mathbf{r}}_{f} - {\mathbf{r}}_{{Ff^{\prime } }} $$.

Exercise 8 (OpenFOAM®)

a.

List all possible gradient type definitions available in OpenFOAM® by modifying the gradSchemes in the fvSchemes dictionary (Hint: just mistype a scheme, e.g., banana, and launch any solver or application, i.e., gradSchemes{default banana;}).

b.

Define in the dictionary file fvSchemes the option to evaluate the explicit gradient with the least square algorithm.

c.

Use the Doxygen documentation [9] to analyze the member function correctBoundaryConditions and explain its operations and aim.

d.

Define in the dictionary file fvSchemes the option to use a limited gradient (face and cell) (Gauss limited 0.8;).

References

1.

Ferziger JH, Peric ́M (2002) Computational Methods for Fluid Dynamics, 3rd edn. Springer, Berlin

2.

Soni B (1998) Hybrid techniques in computational fluid dynamics. Technical Report no. MSSU-COE-ERC-98-3, Engineering Research Center for Computational Field Simulation, Mississippi State University

3.

Frink NT, Parikh P, Pirzadeh S (1991) Aerodynamic Analysis of Complex Configurations Using Unstructured Grids. AIAA 91-3292

4.

Cabello J, Morgon K, Lohner R (1994) A Comparison of Higher Order Schemes Used in a Finite Volume Solver For Unstructured Grids. AIAA 94-2293. Presented at the 25th AIAA Plasmadynamics and Lasers Conference, Colorado Springs, CO

5.

Musaferija I, Gosman D (1997) Finite-Volume CFD procedure and adaptive error control strategy for grids of arbitrary topology. J Comp Phys 138:766–787CrossRef

6.

Barth TJ, Jespersen DC (1989) The design and application of upwind schemes on unstructured meshes. AIAA 89-0366

7.

Ollivier-Gooch C, Van Altena M (2002) A high-order-accurate unstructured mesh finite-volume scheme for the advection–diffusion equation. J Comp Phys 181:729–752MATHCrossRef

8.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

9.

OpenFOAM Doxygen (2015) Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_10

10. Solving the System of Algebraic Equations

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

The result of the discretization process is a system of linear equations of the form $$ {\mathbf{A}}{\varvec{\upphi}} = {\mathbf{b}} $$ where the unknowns $$ {\varvec{\upphi}} $$, located at the centroids of the mesh elements, are the sought after values. In this system, the coefficients of the unknown variables constituting matrix A are the result of the linearization procedure and the mesh geometry, while vector b contains all sources, constants, boundary conditions, and non-linearizable components. Techniques for solving linear systems of equations are generally grouped into direct and iterative methods, with many sub-groups in each category. Since flow problems are highly non-linear, the coefficients resulting from their linearization process are generally solution dependent. For this reason and since an accurate solution is not needed at each iteration, direct methods have been rarely used in CFD applications. Iterative methods on the other hand have been more popular because they are more suited for this type of applications requiring lower computational cost per iteration and lower memory. The chapter starts by presenting few direct methods applicable to structured and/or unstructured grids (Gauss elimination, LU factorization, Tridiagonal and Pentadiagonal matrix algorithms) to set the ground for discussing the more widely used iterative methods in CFD applications. Then the performance and limitations of some of the basic iterative methods with and without preconditioning are reviewed. This include the Jacobi, Gauss-Siedel, Incomplete LU factorization, and the conjugate gradient methods. This is followed by an introduction to the multigrid method that is generally used in combination with iterative solvers to help addressing some of their important limitations.

10.1 Introduction

The starting point for any linear solver is the set of equations generated by the discretization process, which are written mathematically as

(10.1)

where $$ {\mathbf{A}} $$ is the matrix of coefficients of elements $$ a_{ij} ,{\varvec{\upphi}} $$ the vector of unknown variables $$ \phi_{i} $$, and b the vector of sources b i . Using matrix numbering, the expanded form of Eq. (10.1) is given by

(10.2)

Generally each row in the above matrix represents an equation defined over one element of the computational domain, and the non-zero coefficients are those related to the neighbors of that element. The coefficient a ij measures the strength of the link between the value of $$ \phi_{i} $$ at the centroid of the control volume and its neighbors. As a cell is connected to only few neighbors, with their number depending on the connectivity of the elements in the discretized domain, many of the coefficients are zeros and the resulting A matrix is always sparse (i.e., the non-zero coefficients are a very small fraction of the matrix). If in addition the method uses a structured grid system, the matrix A will be banded with all non-zero elements aligned along few diagonals. Therefore methods for efficiently solving such systems should exploit this characteristic.

As mentioned above techniques for solving algebraic systems of equations are broadly divided into two categories denoted by direct and iterative methods, respectively. In a direct method, matrix A is inverted and the solution $$ {\varvec{\upphi}} $$ is computed in one step as $$ {\varvec{\upphi}} = {\mathbf{A}}^{ - 1} {\mathbf{b}} $$. When the matrix A is large, computing its inverse is computationally very expensive requiring large memory. It is basically impractical to apply direct linear solvers in CFD applications as they generally involve nonlinear systems of equations with their coefficients depending on the solution necessitating the use of an iterative process.

On the other hand, with iterative algebraic solvers the solution algorithm is repeatedly applied as many times as required until a pre-assigned level of convergence is reached without the need for a fully converged solution be attained at every iteration.

The presentation starts with few direct linear solvers applicable to structured and unstructured grid methods. This is followed by a description of solution algorithms that take advantage of the banded structure of the coefficient matrix in structured grid systems. The main focus of the chapter is, however, on a specific class of iterative linear algebraic solvers that has been identified to be generally very efficient and economical with the FVM, and has been exclusively implemented as the linear solver in almost all finite volume-based codes.

10.2 Direct or Gauss Elimination Method

Even though direct methods are not efficient at solving sparse systems of linear algebraic equations due to their high computational cost, their discussion will pave the way for introducing efficient iterative methods in the next section. The simplest direct method for finding solutions to the system of equations described by Eq. (10.1) is the Gauss elimination technique, which will be described first. The transformation of the system into an equivalent upper triangular system, when using the Gauss elimination method, has motivated the development of the Lower-Upper (LU) triangulation method, which will also be presented. In this approach, matrix A is decomposed into the product of two matrices L and U with L being a lower triangular matrix and U an upper triangular one. This procedure is also known as LU factorization. In addition, direct methods benefiting from the banded structure of A, applicable to structured grid methods, will be discussed.

10.2.1 Gauss Elimination

The best way to describe the Gauss elimination technique is to start with a simple example. For that purpose a linear system of equations in the two unknowns $$ \phi_{1} $$ and $$ \phi_{2} $$ is considered. The equations are given by

(10.3)

(10.4)

The system can be solved by eliminating one of the variables from one of the equations [say $$ \phi_{1} $$ from Eq. (10.4)]. This can be done by multiplying Eq. (10.3) by $$ a_{21} /a_{11} $$ and subtracting the resulting equation from Eq. (10.4). This yields

(10.5)

The obtained equation involves only one unknown. As such it can be used to solve for $$ \phi_{2} $$, which is obtained as

(10.6)

Knowing $$ \phi_{2} $$, its value can be substituted back into Eq. (10.3) to find $$ \phi_{1} $$. Performing this step, $$ \phi_{1} $$ is found to be

(10.7)

The above procedure is composed of two steps. In the first step the equations are manipulated in order to eliminate one of the unknowns. The end result of this step is an equation with one unknown. In the second step, this equation is solved directly and the result back-substituted into one of the equations to solve for the remaining unknown. The same procedure can be generalized to a system of N equations described by Eq. (10.1) or (10.2), as detailed next.

10.2.2 Forward Elimination

In the derivations to follow, the first row of A refers to the discretized equation for $$ \phi_{1} $$, the second row represents the equation for $$ \phi_{2} $$, and in general the ith row refers to the equation for $$ \phi_{i} $$. The procedure starts by eliminating $$ \phi_{1} $$ from all equations below row 1 in A. To eliminate $$ \phi_{1} $$ from the ith row (i = 2, 3, …, N), the coefficients of the first row are multiplied by $$ a_{i1} /a_{11} $$ and the resulting equation is subtracted from the ith row. The system of equations by the end of this step becomes

(10.8)

Then $$ \phi_{2} $$ is eliminated from all equations below row 2 in the modified A. To eliminate $$ \phi_{2} $$ from the ith row (i = 3, 4, …, N), the coefficients of the second row are multiplied by $$ a_{i2}^{\prime} /a_{22}^{\prime} $$ and the resulting equation is subtracted from the ith row. Then $$ \phi_{3} $$ is eliminated from all rows below the third row in the modified coefficient matrix and the process is continued until $$ \phi_{N - 1} $$ is eliminated from the Nth row leading to the following equivalent system of equations with its matrix A transformed into an upper triangular matrix:

(10.9)

The resulting algorithm is as described below.

10.2.3 Forward Elimination Algorithm

10.2.4 Backward Substitution

The modified system of equations given by Eq. (10.9) indicates that the only unknown in the Nth equation is $$ \phi_{N} $$. Therefore this equation can be used to obtain $$ \phi_{N} $$ as

(10.10)

The (N − 1)th equation is function of $$ \phi_{N - 1} $$ and $$ \phi_{N} $$. Having found $$ \phi_{N} $$ then this equation can be used to find $$ \phi_{N - 1} $$ as

(10.11)

The process continues moving backward and by the time the ith equation is reached, the values $$ \phi_{i + 1} ,\phi_{i + 2} ,\phi_{i + 3} , \ldots ,\phi_{N - 1} ,\phi_{N} $$ would have become available and as such $$ \phi_{i} $$ can be computed using

(10.12)

the process is continued until $$ \phi_{1} $$ is calculated. Algorithmically, this is represented as shown below.

10.2.5 Back Substitution Algorithm

Techniques to improve the performance of the method to avoid division by zero through pivoting (interchanging rows in order to select the largest pivoting element) and to reduce roundoff errors in large systems are available but are not discussed here. Interested readers may consult specialized textbooks on the subject [1–4]. The presented algorithm shows that the method is expensive and the number of operations required to solve a linear system of N equations is proportional to N ³/3 of which only N ²/2 arithmetic operations are required for back substitution. This high computational cost has enticed researchers to look for more efficient specialized solvers for systems with sparse matrices.

10.2.6 LU Decomposition

Another direct method for solving linear algebraic systems of equations is the LU or more generally the PLU (where P refers to the pivoting process mentioned above), in this book reference is made only to LU factorization method, which are variants of the Gauss elimination method. The advantage of these methods over the Gauss elimination method is that once the (P)LU factorization is performed the linear system can be solved as many times as needed for different values of the right hand side vector b without performing any additional elimination, which would still be required with the Gauss method.

Based on the elimination performed in the previous section, Eq. (10.1) was transformed into an upper triangular matrix as given by Eq. (10.9), which can be written as

(10.13)

Using compact matrix notation Eq. (10.13) can be simplified to

(10.14)

Let L be a unit lower triangular matrix (diagonal elements are set to 1 in order to make the factorization unique) given by

(10.15)

such that if Eq. (10.14) is multiplied by L, Eq. (10.1) is recovered. If this holds, then the following can be written:

(10.16)

Based on matrix properties it follows that

(10.17)

and

(10.18)

Equation (10.17) indicates that A is written as the product of a proper lower and an upper triangular matrix, known as LU factorization.

10.2.7 The Decomposition Step

The efficient procedure to find the L and U coefficients described next is denoted by the Crout decomposition [1–4]. In the original Crout algorithm a unit upper triangular matrix is used whereas here a unit lower triangular matrix is assumed. The procedure is based on multiplying L and U to obtain A such that

(10.19)

The calculation of the coefficients starts by multiplying the first row of L by all columns of U, and equating with the corresponding coefficients of A to yield

(10.20)

Then the second through Nth rows of L are multiplied by the first column of U leading to

(10.21)

The process is repeated by multiplying the second row of L by the second through Nth columns of U to give

(10.22)

after that the third through Nth rows of L are multiplied by the second column of U to give

(10.23)

In general, the ith row of L is multiplied by the ith through Nth columns of U, resulting in

(10.24)

and the (i + 1)th through Nth rows of L are multiplied by the ith column of U, giving

(10.25)

For the Nth row of L, its coefficients are multiplied by the coefficients of the Nth column of U from which u NN is obtained as

(10.26)

A summary of the LU factorization is shown algorithmically below.

10.2.8 LU Decomposition Algorithm

10.2.9 The Substitution Step

Having decomposed the original matrix A into L and U, the system of equations can be solved in a two step procedure via Eqs. (10.18) and (10.14). Note that the two-step procedure is equivalent to solving two linear systems of equations but now simplified by the fact that L and U are of lower and upper triangular form, respectively.

In the first step the vector c is obtained from Eq. (10.18) by forward substitution. The process can be described as

(10.27)

In the second step, the $$ \phi $$ values are found from Eq. (10.14) by back substitution. The process is described by

(10.28)

The elements of L and U can be directly stored in the original matrix A if it is no longer needed. This is because the elements of A are only needed when the corresponding elements of either L or U are calculated. The number of operations required to perform the LU factorization of a square matrix of size N × N is 2N ³/3, which is double the number of operations required to solve the same system of equations by Gauss elimination. Again the advantage of using LU factorization is when the same matrix A applies to many systems with different b vectors. Nevertheless, the main reason for introducing the LU factorization is because it forms the basis for developing some of the more efficient iterative solvers of linear algebraic systems of equations, which will be introduced in the next section.

10.2.10 LU Decomposition and Gauss Elimination

It may not be apparent, but Gauss elimination can be used to perform LU decomposition. It was shown that the forward elimination step results in an upper triangular matrix U. In the process however, L is actually produced. The elements of L are the factors (denoted by ratio in the Gauss elimination algorithm) by which the rows are multiplied during the various elimination steps. The below algorithm, which assumes a unit lower triangular matrix L, performs the LU decomposition of A by Gauss elimination.

10.2.11 LU Decomposition Algorithm by Gauss Elimination

Example 1

Solve the following system of linear algebraic equations using the LU decomposition technique:

Solution

The system is of the form $$ {\mathbf{A}}{\varvec{\upphi}} = b $$. The L and U should satisfy

Following the procedure described above the elements are calculated as follows:

Therefore the L and U matrices are given by

The c vector should satisfy

with its solution obtained as

The solution to the original equation is obtained by solving

with the solution found as

10.2.12 Direct Methods for Banded Sparse Matrices

The Gauss elimination and LU decomposition methods are applicable to any system of equations. In specific it can be used for solving the system of equations resulting from the discretization of the conservation equations of interest in this book on structured or unstructured grid networks. When a structured grid method is used the discretization process results in a system of equations with the non-zero elements of its matrix of coefficients aligning along few diagonals. Depending on the discretization stencil used and the dimension of the problem being solved, tridiagonal or pentadiagonal matrices may arise, for which efficient algorithms have been developed as described next.

10.2.13 TriDiagonal Matrix Algorithm (TDMA)

The TriDiagonal Matrix Algorithm (TDMA), also known as Thomas algorithm [5, 6], solves the system of algebraic equations with a tridiagonal coefficient matrix written as

(10.29)

For the grid arrangement adopted in this book, i refers to the grid point location shown in Fig. 10.1.

Fig. 10.1

One dimensional grid arrangement

For i = 1 the equation can be used to solve for $$ \phi_{1} $$ in term of $$ \phi_{2} $$ as

(10.30)

Similarly for i = 2 Eq. (10.29) with the help of Eq. (10.30) allows expressing $$ \phi_{2} $$ solely in term of $$ \phi_{3} $$ as

(10.31)

The same can be repeated for $$ \phi_{3} $$ through $$ \phi_{N} $$ suggesting that in general $$ \phi_{i} $$ can be expressed as function of $$ \phi_{i + 1} $$ according to

(10.32)

Equation (10.32) for i − 1 when combined with Eq. (10.29) results in

(10.33)

Comparing Eq. (10.32) with Eq. (10.33) the following recurrence relations for P i and Q i are found:

(10.34)

For i = 1 the values for P ₁ and Q ₁ are computed from Eq. (10.30) as

(10.35)

For i = N, since b N  = 0 the following is deduced:

(10.36)

The TDMA solution algorithm can be summarized as follows:

10.2.14 PentaDiagonal Matrix Algorithm (PDMA)

The PentaDiagonal Matrix Algorithm (PDMA) [7–10], solves the system of algebraic equations with a pentadiagonal coefficient matrix arising from discretization schemes that relate the value of $$ \phi_{i} $$ at grid point i to the values at its two upstream (i − 1 and i − 2) and two downstream (i + 1 and i + 2) neighboring node values. For the notation illustrated schematically in Fig. 10.1, the general algebraic equation is written as

(10.37)

Subject to

(10.38)

For i = 1, Eq. (10.37) gives

(10.39)

while for i = 2 the value of $$ \phi_{2} $$ is found to be

(10.40)

The process can be continued for other values of i and in general $$ \phi_{i} $$ can be expressed as

(10.41)

Computing $$ \phi_{i - 1} $$ and $$ \phi_{i - 2} $$ using Eq. (10.41) and substituting their values in Eq. (10.37), an equation for $$ \phi_{i} $$ is derived as

(10.42)

Comparing Eqs. (10.41) and (10.42) P i , Q i , and R i are found as

(10.43)

with their values for i = 1 and 2 given by

(10.44)

Since $$ b_{N - 1} = b_{N} = c_{N} = 0 $$ then $$ P_{N - 1} = P_{N} = Q_{N} = 0 $$. Thus, the equations for $$ \phi_{N - 1} $$ and $$ \phi_{N} $$ are found from

(10.45)

The PDMA solution algorithm can be summarized as follows:

10.3 Iterative Methods

Direct methods are generally not appropriate for solving large systems of equations particularly when the coefficient matrix is sparse, i.e., when most of the matrix elements are zero. This is more so when the linearized system of equations is nonlinear with solution dependent coefficients, or when dealing with time dependent problems. This is exactly the type of equations encountered when solving fluid flow problems.

In contrast, iterative methods are more appealing for these problems since the solution of the linearized system becomes part of the iterative solution process. Add to that the low computer storage and low computational cost requirements of this approach relative to the direct method.

There are many families of iterative methods and for a thorough review of this approach the reader is directed to dedicated books on the topic [11–14]. In this chapter a brief examination of basic iterative methods is provided along with an appraisal of multigrid algorithms that are generally used to address their deficiency. The Gauss elimination and LU decomposition direct methods were introduced for the sole purpose of clarifying some fundamental numerical processes needed for understanding iterative methods.

To unify the presentation of these methods, the coefficient matrix will be written in the following form:

(10.46)

where D, L, and U refers to a diagonal, strictly lower, and strictly upper matrix, respectively.

Iterative methods for solving a linear system of the type $$ {\mathbf{A}}{\varvec{\upphi}} = {\mathbf{b}} $$, compute a series of solutions $$ {\varvec{\upphi}}^{\left( n \right)} $$ that, if certain conditions are satisfied, converge to the exact solution $$ {\varvec{\upphi}} $$. Thus, for the solution, a starting point is chosen (i.e., $$ {\varvec{\upphi}}^{\left( 0 \right)} $$ is selected as the initial condition or initial guess) and an iterative procedure that computes $$ {\varvec{\upphi}}^{\left( n \right)} $$ from the previously computed $$ {\varvec{\upphi}}^{{\left( {n - 1} \right)}} $$ field is developed.

A “fixed-point” iteration can always be associated to the above system by decomposing matrix A as

(10.47)

Using this decomposition, Eq. (10.1) is rewritten as

(10.48)

Applying a fixed point iteration solution procedure, Eq. (10.48) becomes

(10.49)

which can be rewritten in the following form:

(10.50)

where $$ {\mathbf{B}} = {\mathbf{M}}^{ - 1} {\mathbf{N}} $$ and $$ {\mathbf{C}} = {\mathbf{M}}^{ - 1} $$. Different choices of these matrices define different iterative methods.

Before embarking on the description of the various iterative methods, a minimal set of characteristics that an iterative method should possess to guarantee convergence is first presented.

A.

The iterative equation can be written at convergence as

(10.51)

which, after rearranging, becomes

(10.52)

Comparing Eq. (10.52) with Eq. (10.1), the coefficient matrix is obtained as

(10.53)

or, alternatively, as

(10.54)

This relation between the various matrices ensures that once the exact solution is reached all consecutive iterations will not modify it.

B.

Starting from some guess $$ {\varvec{\upphi}}^{\left( 0 \right)} \ne {\varvec{\upphi}} $$, the method should guarantee that $$ {\varvec{\upphi}}^{\left( n \right)} $$ will converge to $$ {\varvec{\upphi}} $$ as n increases. Since $$ {\varvec{\upphi}}^{\left( n \right)} $$ can be expressed in terms of $$ {\varvec{\upphi}}^{\left( 0 \right)} $$ as

(10.55)

then, for the above to be true, B should satisfy

(10.56)

Equation (10.56) implies that the spectral radius of B should be less than 1, i.e.,

(10.57)

This condition guaranties that the iterative method is self corrective, i.e., it is robust to any error adversely inserted into the solution vector $$ {\varvec{\upphi}} $$.

More insight into the above condition can be obtained by defining the error e (n) in the solution as the difference between the exact value and the value at any iteration (n), then

(10.58)

Subtracting Eq. (10.51) from Eq. (10.50) and using the definitions in Eq. (10.58), a relation between the error at iteration n and n − 1 is obtained as

(10.59)

Thus, for the method to converge, the following should be satisfied:

(10.60)

To translate Eq. (10.60) into something meaningful, the eigenvectors of B are assumed to be complete and to form a full set, meaning that they form a basis for R N . This being the case then e can be expressed as a linear combination of the N eigenvectors v of B. That is

(10.61)

with each of the eigenvectors satisfying

(10.62)

where $$ \lambda_{i} $$ is the eigenvalue corresponding to the eigenvector v i . Starting with the first iteration, Eq. (10.59) gives

(10.63)

For the second iteration, the error is obtained as

(10.64)

This procedure can be continued and it is easily shown by induction that

(10.65)

Therefore for the iterative procedure to converge as n approaches infinity, all eigenvalues should be less than 1. If any of them is greater than 1 then the error will tend to infinity. This explains the importance of the spectral radius ρ of the matrix B defined as

(10.66)

that was mentioned above. The convergence of iterative methods is accelerated by reducing the spectral radius of the iterative matrix. This is at the heart of iterative techniques.

C.

Some type of a stopping criterion is needed with iterative methods. Many used criteria are based on a variation of the norm of the residual error defined as

(10.67)

One criterion is to find the maximum residual in the domain and to require its value to become less than some threshold ε to declare a solution converged, i.e.,

(10.68)

or that the root mean square residual be smaller than ε, i.e.,

(10.69)

Another possible criterion is for the maximum normalized difference between two consecutive iterations to drop below $$ \varepsilon $$. This condition can be written as

(10.70)

10.3.1 Jacobi Method

Perhaps the simplest of the iterative methods for solving a linear system of equations is the Jacobi method, which is graphically presented in Fig. 10.2.

Fig. 10.2

A graphical representation of the Jacobi method

Considering the system of equations described by Eq. (10.1), if the diagonal elements are nonzero, then the first equation can be used to solve for $$ \phi_{1} $$, the second equation to solve for $$ \phi_{2} $$, and so on. The solution process starts by assigning guessed values to the unknown vector $$ {\varvec{\upphi}} $$. These guessed values are used to calculate new estimates starting with $$ \phi_{1} $$, then $$ \phi_{2} $$, and computations proceed until a new estimate for $$ \phi_{N} $$ is computed. This represents one iteration. Results obtained are treated as a new guess for the next iteration and the solution process is repeated. Iterations continue until the changes in the predictions between two consecutive iterations drop below a vanishing value or until a preset convergence criterion is satisfied. Once this happens the final solution is reached. In this method, given some current estimate $$ \phi^{{\left( {n - 1} \right)}} $$, an update is obtained using the following relation:

(10.71)

Equation (10.71) indicates that values obtained during an iteration are not used in the subsequent calculations during the same iteration but rather retained for the next iteration. Using matrices, the expanded form of Eq. (10.71) is given by

(10.72)

Solving for $$ {\varvec{\upphi}}^{\left( n \right)} $$, Eq. (10.72) yields

(10.73)

Using Eqs. (10.46) and (10.73) can be more concisely written as

(10.74)

The Jacobi method converges as long as $$ \rho \left( { - {\mathbf{D}}^{ - 1} \left( {{\mathbf{L}} + {\mathbf{U}}} \right)} \right) < 1 $$. This condition is satisfied for a large class of matrices including diagonally dominant ones where their coefficients satisfy

(10.75)

10.3.2 Gauss-Seidel Method

A more popular take on the Jacobi is the Gauss-Seidel method, which has better convergence characteristics. It is somewhat less expensive memory-wise since it does not require storing the new estimates in a separate array. Rather, it uses the latest available estimate of $$ \phi $$ in its calculations. The iterative formula in the Gauss Seidel method, schematically displayed in Fig. 10.3, is given as

(10.76)

In matrix form Eq. (10.76) is written as

(10.77)

In effect the Gauss-Seidel method uses the most recent values in its iteration, specifically all $$ \phi_{j}^{\left( n \right)} $$ values for j < i since by the time $$ \phi_{i} $$ is to be calculated, the values of $$ \phi_{1} ,\phi_{2} ,\phi_{3} , \ldots ,\phi_{i - 1} $$ at the current iteration are already calculated. This approach also saves memory since the newer value is always overwriting the previous one. The Gauss-Seidel iterations converge as long as

(10.78)

Although in some cases the Jacobi method converges faster, Gauss-Seidel is the preferred method.

Fig. 10.3

A graphical representation of the Gauss-Seidel method

Example 2

Apply 5 iterations of the Gauss-Seidel and Jacobi methods to the system of equations in Example 1 and compute the errors at each iteration using the exact solution.

As an initial guess start with the field $$ {\boldsymbol{\upphi}^{*}} = \left[ {\begin{array}{*{20}c} 0 & 0 & 0 & 0 \\ \end{array} } \right] $$

Solution

Denoting with a superscript $$ (^{*} ) $$ values from the previous iteration, the equations to be solved in the Jacobi method are as follows:

with the error given as $$ {\varvec{\upvarepsilon}} = \left| {{\varvec{\upphi}}_{exact} - {\varvec{\upphi}}_{computed} } \right| $$. The solution for the first iteration is obtained as

Computations proceed in the same manner with solution obtained treated as the new guess. The results for the first five iterations are given in Table 10.1.

Table 10.1

Summary of results obtained using the Jacobi iterative method

Iter #

0

0

1.4548

0

1.3645

0

1.2776

0

0.06354

1

1

0.4548

0.6667

0.6978

0.8333

0.4443

−0.4286

0.3650

2

1.2222

0.2326

1.1389

0.2257

0.9841

0.2935

−0.1905

0.1269

3

1.3796

7.52E−02

1.2381

0.1265

1.1812

9.64E−02

−0.1474

8.38E−02

4

1.4127

4.22E−02

1.3234

4.11E−02

1.2215

5.61E−02

−9.11E−02

2.75E−02

5

1.4411

1.37E−02

1.3411

2.34E−02

1.2593

1.83E−02

−7.96E−02

1.6E−02

Denoting with a superscript $$ (^{*} ) $$ values from the previous iteration, the equations to be solved in the Gauss-Seidel method are as follows:

with the error given as $$ {\varvec{\upvarepsilon}} = \left| {{\varvec{\upphi}}_{exact} - {\varvec{\upphi}}_{computed} } \right| $$. The solution for the first iteration is obtained as

Computations proceed in the same manner with solution obtained treated as the new guess. The results for the first five iterations are given in Table 10.2.

Table 10.2

Summary of results obtained using the Gauss-Siedel iterative method

Iter #

0

0

1.4548

0

1.3645

0

1.2776

0

0.06354

1

1

0.4548

1

0.3645

1.1667

0.1109

−0.09523

0.03169

2

1.3333

0.1215

1.3056

5.90E−02

1.2526

2.49E−02

−7.07E−02

7.13E−03

3

1.4352

1.97E−02

1.3538

1.07E−02

1.2728

4.76E−03

−6.49E−02

1.36E−03

4

1.4513

3.57E−03

1.3626

1.98E−03

1.2767

8.88E−04

−6.38E−02

2.54E−04

5

1.4542

6.61E−04

1.3642

3.68E−04

1.2774

1.65E−04

−6.36E−02

4.72E−05

10.3.3 Preconditioning and Iterative Methods

The rate of convergence of iterative methods depends on the spectral properties of the iteration matrix B, which is contingent on the matrix of coefficients. Based on that an iterative method looks for a transformation of the system of equations into an equivalent one that has the same solution, but of better spectral properties. Under these conditions the eigenvalues of the equivalent system are more clustered allowing the iterative solution to be obtained faster than with the original system. A preconditioner is defined as a matrix that effects such a transformation.

A preconditioning matrix P is defined such that the system

(10.79)

has the same solution as the original system $$ {\mathbf{A}}{\varvec{\upphi}} = {\mathbf{b}} $$, but the spectral properties of its coefficient matrix $$ {\mathbf{P}}^{ - 1} {\mathbf{A}} $$ are more conducive. In defining the preconditioner P, the difficulty is to find a matrix that approximates $$ {\mathbf{A}}^{ - 1} $$ and is easy to invert (i.e., to find $$ {\mathbf{P}}^{ - 1} $$) at a reasonable cost.

Writing again Eq. (10.47), but now with P replacing M (i.e., M = P and A = P − N) the associated fixed point iteration system is given by

(10.80)

which in residual form can be written as

(10.81)

From both equations it is now clear that the iterative procedure is just a fixed-point iteration on a preconditioned system associated with the decomposition A = P − N where the spectral properties are now

(10.82)

By comparison, the preconditioning matrix for the Jacobi $$ \left( J \right) $$ and Gauss-Seidel $$ \left( {GS} \right) $$ methods are simply

(10.83)

where D and L are respectively the diagonal and lower triangular part of matrix A.

Thus, preconditioning is a manipulation of the original system to improve its spectral properties with the preconditioning matrix P used in the associated iterative procedure. As will be described in the following sections, it is possible to develop more advanced preconditioning matrices in which the coefficients are defined in a more complex way.

10.3.4 Matrix Decomposition Techniques

The low rate of convergence of the Gauss-Seidel and Jacobi methods was the prime motivator for the development of faster iterative techniques. One approach to accelerate the convergence rate of solvers and to develop iterative methods is through the use of more advanced preconditioners. A simple, yet efficient, approach for that purpose is to perform an incomplete factorization of the original matrix of coefficients A. The stress on incomplete is essential since a complete factorization of A into a lower L and an upper triangular matrix U is tantamount to a direct solution and is very expensive in term of memory requirements (fill in and loss of sparsity) and computational cost.

10.3.5 Incomplete LU (ILU) Decomposition

As can be seen in Example 1, the L and U matrices result in non-zero elements at locations that were 0 in the original matrix A (this is known as fill-in). So if an incomplete LU (ILU) factorization of A is performed such that the resulting lower L and upper U matrices have the same nonzero structure as the lower and upper parts of A, then

(10.84)

where R is the residual of the factorization procedure. The matrices L and U being sparse (same structure as A) are easier to deal with then if they were obtained from a complete factorization. However, their product being an approximation to A, necessitates the use of an iterative solution procedure to solve the system of equations. The first step in the solution process is to rewrite Eq. (10.1) as

(10.85)

Denoting values obtained from the previous iteration with a superscript $$ \left( {n - 1} \right) $$, and values obtained at the current iteration with superscript $$ \left( n \right) $$, the iterative process is obtained by rewriting Eq. (10.85) in the following form:

(10.86)

Therefore values of $$ {\varvec{\upphi}}^{\left( n \right)} $$ at the current iteration can be obtained from knowledge of $$ {\varvec{\upphi}}^{{\left( {n - 1} \right)}} $$ values obtained at the previous iteration. Equation (10.86) is usually solved in residual form whereby the solution $$ {\varvec{\upphi}}^{\left( n \right)} $$ at iteration $$ \left( n \right) $$ is expressed in terms of the solution $$ {\varvec{\upphi}}^{{\left( {n - 1} \right)}} $$ at iteration $$ \left( {n - 1} \right) $$ plus a correction $$ {\boldsymbol{\upphi}}^{{\prime}{\left( n \right)}} $$, i.e.,

(10.87)

Thus Eq. (10.86) becomes

(10.88)

Once $$ {\varvec{\upphi}}^{{\prime}{\left( n \right)}} $$ is found, Eq. (10.87) is used to update ϕ at every iteration.

The ILU factorization can be performed using Gaussian elimination while dropping some non diagonal elements at preset locations. The locations where elements are to be dropped give rise to different ILU approximations.

10.3.6 Incomplete LU Factorization with no Fill-in ILU(0)

Many variants of the ILU factorization technique exist and the simplest is the one denoted by ILU(0) [15–17]. In ILU(0) the pattern of zero elements in the combined L and U matrices is taken to be precisely the pattern of zero elements in the original matrix A. Using Gaussian elimination, computations are performed as in the case of a full LU factorization, but any new nonzero element ($$ \ell_{ij} $$ and $$ u_{ij} $$) arising in the process is dropped if it appears at a location where a zero element exists in the original matrix A. Hence, the combined L and U matrices have together the same number of non zeros as the original matrix A. With this approach, the fill-in problem that usually arises when factorizing sparse matrices (i.e., the creation of nonzero elements at locations where the original matrix has zeros) is eliminated. In the process however, the accuracy is reduced thereby increasing the number of required iterations for convergence to be reached. To remedy this shortcoming, more accurate ILU factorization methods, which are often more efficient and more reliable, have been developed. These methods, differing by the level of fill-in allowed, are denoted by ILU(p) where p represents the order of fill-ins. The higher the level of fill-ins, the more expensive the ILU decomposition step becomes. Moreover, when used within a multigrid approach (to be explained in a later section), the ILU(0) method is more than adequate as a smoother. For this reason higher level methods are not presented and for more information interested readers are referred, among others, to the book by Saad [12].

An ILU(0) factorization algorithm which assumes L to be a unit lower triangular matrix and for which the same matrix A is used to store the elements of the unit lower and upper triangular matrices L and U is as given next.

10.3.7 ILU(0) Factorization Algorithm

It should be mentioned that the ILU decomposition of symmetric positive definite matrices is denoted by Incomplete Cholesky decomposition. In this case the factorization is made just of the lower (or upper) triangular part and the approximation to the original matrix is written as

(10.89)

where $$ {\bar{\mathbf{L}}} $$ is the factorized sparse lower triangular matrix (approximation of L), with the preconditioning matrix P given by

(10.90)

10.3.8 ILU Factorization Preconditioners

A very popular class of preconditioners is based on incomplete factorizations. In the discussions of direct methods it was shown that decomposing a sparse matrix A into the product of a lower and an upper triangular matrices may lead to substantial fill-in. Because a preconditioner is only required to be an approximation to $$ {\mathbf{A}}^{ - 1} $$, it is sufficient to look for an approximate decomposition of $$ {\mathbf{A}} $$ such that $$ {\mathbf{A}} \approx {\overline{\mathbf{L}}}\,{\overline{\mathbf{U}}} $$. Choosing $$ {\mathbf{P}} = {\overline{\mathbf{L}}}\,{\overline{\mathbf{U}}} $$ leads also to an efficient evaluation of the inverse of the preconditioned matrix $$ {\mathbf{P}}^{ - 1} $$ since the inversion can easily be performed by the forward and backward substitution, as described above, in which the exact L and U are now replaced by the approximations $$ {\overline{\mathbf{L}}} $$ and $$ \overline{{\mathbf{U}}} $$, respectively.

For the ILU(0) method, the incomplete factorization mimics the nonzero elements sparsity of the original matrix such that the pre-conditioner has exactly the size of the original matrix. In order to reduce the storage needed, Pommerell introduced a simplified version of the ILU called diagonal ILU (DILU) [18]. In the DILU the fill-in of the off-diagonal elements is eliminated (i.e., the upper and lower parts of the matrix are kept unchanged) and only the diagonal elements are modified.

In this case it is possible to write the preconditioner in the form

(10.91)

where L and U are the lower and upper triangular decomposition of A, and $$ {\mathbf{D}}^{*} $$ is now a proper diagonal matrix, different from the diagonal of A. The $$ {\mathbf{D}}^{*} $$ matrix is thus defined, as shown below, in a way that the diagonal of the product of the matrices in Eq. (10.91) equals the diagonal of A.

10.3.9 Algorithm for the Calculation of $$ {\mathbf{D}}^{*} $$ in the DILU Method

In this case the inverse of the preconditioner, which is defined as

(10.92)

needed in the solution of $$ {\mathbf{P}} {\varvec{\upphi}}^{{\prime}{{\left( {n + 1} \right)}}} = {\mathbf{r}}^{\left( n \right)} $$ to find the correction field $$ {\varvec{\upphi}}^{{\prime}{{\left( {n + 1} \right)}}} = {\mathbf{P}}^{ - 1} {\mathbf{r}}^{\left( n \right)} $$, can easily be calculated using the following forward and backward substitution algorithm.

10.3.10 Forward and Backward Solution Algorithm with the DILU Method

The clear advantage of the DILU, apart from its recursive formulation, is that it requires only one extra diagonal of storage.

10.3.11 Gradient Methods for Solving Algebraic Systems

Another group of iterative procedures for solving linear algebraic systems of equations is the Gradient Methods, which include the Steepest Descent and the Conjugate Gradient methods. They were initially developed for cases where the coefficient matrix A is symmetric positive definite (SPD) to reformulate the problem as a minimization problem for the quadratic vector function $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$ given by

(10.93)

where c is a vector of scalars, and other variables are as defined in Eq. (10.1). The minimum of $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$ is obtained when its gradient with respect to $$ {\varvec{\upphi}} $$ is zero. The gradient $$ {\mathbf{Q}}^{\prime } \left( {\varvec{\upphi}} \right) $$ of a vector field $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$, at a given $$ {\varvec{\upphi}} $$, points in the direction of greatest increase of $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$. Through mathematical manipulations the gradient is found as

(10.94)

If A is symmetric $$ \left( {{\mathbf{A}} = {\mathbf{A}}^{\text{T}} } \right) $$, then Eq. (10.94) implies

(10.95)

The minimum is obtained when $$ {\mathbf{Q}}^{\prime } \left( {\varvec{\upphi}} \right) = 0 $$, leading to

(10.96)

Therefore minimizing $$ {\mathbf{Q}}\left(\varvec{\upphi}\right) $$ is equivalent to solving Eq. (10.1) and the solution of the minimization problem yields the solution of the system of linear equations.

Now for the function $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$ to have a global minimum it is necessary for the coefficient matrix A to be positive definite, i.e., it should satisfy the inequality $$ {\varvec{\upphi}}^{{T}} {\mathbf{A}}{\varvec{\upphi}} > 0 $$ for all $$ {\varvec{\upphi}} \ne {\mathbf{0}} $$. This requirement can be established by considering the relationship between the exact solution $$ {\varvec{\upphi}} $$ and its current estimate $$ {\varvec{\upphi}}^{\left( n \right)} $$. If $$ {\mathbf{e = }}{\varvec{\upphi}}^{\left( n \right)} - {\varvec{\upphi}} $$ denotes the difference between the exact solution and the current estimate, then Eq. (10.93) gives

(10.97)

indicating that if A is positive definite, the second term will be always positive except when e = 0, in which case the required solution would have been obtained. Moreover, when A is positive definite, all its eigenvalues are positive and the function $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$ has a unique minimum.

Thus with a symmetric and positive definite matrix a converging series of $$ {\varvec{\upphi}}^{\left( n \right)} $$ can be derived such that

(10.98)

where $$ \alpha^{\left( n \right)} $$ is some relaxation factor, and $$ {\varvec{\updelta}}{\varvec{\upphi}}^{\left( n \right)} $$ is related to the correction needed to minimize the said function at each iteration. This can be accomplished in a variety of ways leading to different methods.

10.3.12 The Method of Steepest Descent

The method of steepest descent for solving linear systems of equations of the form given by Eq. (10.1) is based on minimizing the quadratic form given by Eq. (10.93). If $$ {\varvec{\upphi}} $$ is a one dimensional vector with its components given by the scalar $$ \phi $$, then $$ {\varvec{Q}}\left( \phi \right) $$ will represent a parabola. Finding the minimum of a parabolic function iteratively starting at some point $$ \phi_{0} $$, involves moving down along the parabola until hitting the minimum.

The same idea is used in N dimensions. In this case $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$ may be depicted as a paraboloid and the solution is iteratively found starting from an initial position $$ {\varvec{\upphi}}^{\left( 0 \right)} $$ and moving down the paraboloid until the minimum is reached. For quick convergence the sequence of steps $$ {\varvec{\upphi}}^{\left( 0 \right)} ,{\varvec{\upphi}}^{\left( 1 \right)} ,{\varvec{\upphi}}^{\left( 2 \right)} , \ldots $$ should be selected such that the fastest rate of descent occurs, i.e., in the direction of $$ - {\mathbf{Q^{\prime}}}\left( {\varvec{\upphi}} \right) $$. According to Eq. (10.95) this direction is also given by

(10.99)

The exact solution being $$ {\varvec{\upphi}} $$, the error and residual at any step n, denoted respectively by $$ {\mathbf{e}}^{\left( n \right)} $$ and $$ {\mathbf{r}}^{\left( n \right)} $$, are computed as

(10.100)

Moving linearly in the direction of the steepest descent, the value of $$ {\varvec{\upphi}} $$ at step n + 1 can be expressed in terms of the value of $$ {\varvec{\upphi}} $$ at step n according to

(10.101)

The value of $$ \alpha^{\left( n \right)} $$ that minimizes $$ {\mathbf{Q}}\left( {\varvec{\upphi}} \right) $$ should satisfy

(10.102)

This can be expanded into

(10.103)

indicating that the new step should be in a direction normal to the old step. The value of $$ \alpha^{\left( n \right)} $$ is calculated by using Eq. (10.103) as follows:

(10.104)

The steepest descent algorithm can be summarized as follows:

As presented above, the algorithm necessitates performing two matrix-vector multiplications per iteration. One of them can be eliminated by multiplying both sides of Eq. (10.101) by −A and adding b to obtain

(10.105)

The equation for $$ {\mathbf{r}}^{\left( n \right)} $$ in step 1 is needed only to calculate $$ {\mathbf{r}}^{\left( 0 \right)} $$, while Eq. (10.105) can be used afterwards. With this formulation there will be no need to compute $$ {\mathbf{A}}{\varvec{\upphi}}^{\left( n \right)} $$, as it was replaced by $$ {\mathbf{Ar}}^{\left( n \right)} $$. However a shortcoming of this approach, is the lack of feedback from the value of $$ {\varvec{\upphi}}^{\left( n \right)} $$ into the residual, which may cause the solution to converge to a value different from the exact one due to accumulation of roundoff errors. This deficiency can be resolved by periodically computing the residual using the original equation.

10.3.13 The Conjugate Gradient Method

While the steepest descent method guarantees convergence, its rate of convergence is low. This slow convergence is caused by oscillations around local minima forcing the method to search in the same direction repeatedly. To avoid this undesirable behavior every new search should be in a direction different from the directions of previous searches [19]. This can be accomplished by selecting a set of search directions $$ {\mathbf{d}}^{{\left( {0} \right)}} ,{\mathbf{d}}^{{\left( {1} \right)}} ,{\mathbf{d}}^{{\left( {2} \right)}} , \ldots , {\mathbf{d}}^{{\left( {{N - 1}} \right)}} $$ that are A-orthogonal. Two vectors $$ {\mathbf{d}}^{\left( n \right)} $$ and $$ {\mathbf{d}}^{\left( m \right)} $$ are said to be A-orthogonal if they satisfy the following condition:

(10.106)

If in each search direction the right step size is taken, the solution will be found after N steps. Step n + 1 is chosen such that

(10.107)

Subtracting ϕ from both sides of the above equation, an equation for the error is obtained as

(10.108)

Combining Eq. (10.100) with Eq. (10.108), an equation for the residual is found as

(10.109)

Equation (10.109) shows that each new residual $$ {\mathbf{r}}^{{\left( {n + 1} \right)}} $$ is just a linear combination of the previous residual and $$ {\mathbf{Ad}}^{\left( n \right)} $$.

It is further required that $$ {\mathbf{e}}^{{\left( {n + 1} \right)}} $$ be A-orthogonal to $$ {\mathbf{d}}^{\left( n \right)} $$. This new condition is equivalent to finding the minimum point along the search direction $$ {\mathbf{d}}^{\left( n \right)} $$. Using this A-orthogonality condition between $$ {\mathbf{e}}^{{\left( {n + 1} \right)}} $$ and $$ {\mathbf{d}}^{\left( n \right)} $$ along with Eq. (10.108) an expression for $$ \alpha^{\left( n \right)} $$ can be derived as

(10.110)

The above requirement also implies that

(10.111)

If the search directions are known then $$ \alpha^{\left( n \right)} $$ can be calculated.

To derive the search direction, it is assumed to be governed by an equation of the form

(10.112)

The A-orthogonality requirement of the d vectors implies that

(10.113)

Substituting the value of $$ {\mathbf{d}}^{{\left( {n + 1} \right)}} $$ from Eq. (10.112) in Eq. (10.113) yields

(10.114)

From Eq. (10.109) an expression for $$ {\mathbf{Ad}}^{\left( n \right)} $$ is obtained as

(10.115)

Combining Eqs. (10.110), (10.114), and (10.115) leads to

(10.116)

The denominator of the above equation can be further expressed as

(10.117)

Using Eqs. (10.116) and (10.117), the final expression for $$ \beta^{\left( n \right)} $$ is obtained as

(10.118)

The Conjugate Gradient algorithm becomes

The convergence rate of the CG method may be increased by preconditioning. This can be done by multiplying the original system of equations by the inverse of the preconditioned matrix $$ {\mathbf{P}}^{ - 1} $$, where $$ {\mathbf{P}} $$ is a symmetric positive-definite matrix, to yield Eq. (10.79). The problem is that $$ {\mathbf{P}}^{ - 1} {\mathbf{A}} $$ is not necessarily symmetric even if $$ {\mathbf{P}} $$ and $$ {\mathbf{A}} $$ are symmetric. To circumvent this problem the Cholesky decomposition is used to write $$ {\mathbf{P}} $$ in the form

(10.119)

To guarantee symmetry, the system of equations is written as

(10.120)

where $$ {\mathbf{L}}^{ - 1} {\mathbf{AL}}^{{ - {\text{T}}}} $$ is symmetric and positive-definite. The CG method can be used to solve for $$ {\mathbf{L}}^{\text{T}} {\varvec{\upphi}} $$, from which ϕ is found. However, by variable substitutions, $$ {\mathbf{L}} $$ can be eliminated from the equations without disturbing symmetry or affecting the validity of the method. Performing this step and adopting the terminology used with the CG method, the various steps in the preconditioned CG method are obtained.

The preconditioned CG method can be summarized as follows:

Many pre-conditioners have been developed with a wide spectrum of sophistication varying from a simple diagonal matrix whose elements are the diagonal elements of the original matrix A (Jacobi pre-conditioner) to more involved ones using incomplete Cholesky factorization. Nonetheless, the CG method should always be used with a pre-conditioner when solving large systems of equations.

10.3.14 The Bi-conjugate Gradient Method (BiCG) and Preconditioned BICG

The matrix of coefficients resulting from the discretization of the diffusion equation presented in Chap. 8 and some other equations like the incompressible pressure or pressure correction equation that will be presented in Chap. 15 are symmetrical leading to symmetrical systems that can be solved using the CG method discussed above. However, the matrix $$ {\mathbf{A}} $$ obtained from the discretization of the general conservation equation arising in CFD applications is unsymmetrical yielding an unsymmetrical system of equations. To be able to solve this system using the CG method, it should be transformed into a symmetrical one [20]. One way to do that is to rewrite Eq. (10.1) as

(10.121)

where $$ {\varvec{\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{\upphi} }}$$ is a dummy variable added in order to convert the original unsymmetrical system into a symmetrical one amenable to a solution by the CG method. When applied to this system, the CG method results in two sequences of CG-like vectors, the ordinary sequence based on the original system with the coefficient matrix A, from which ϕ is calculated, and the shadow sequence for the unneeded system with the coefficient matrix $$ {\mathbf{A}}^{\text{T}} $$, from which $${\varvec{\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{\upphi} }}$$ can be calculated if desired. Because of the two series of vectors the name bi-conjugate gradient (BiCG) is coined to the method. The same terminology used with the CG method is used here. The series of ordinary vectors for the residuals and search directions are denoted by r and d, respectively, and their shadow equivalent forms by $$ {\mathbf{\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{r} }} $$ and $$ {\mathbf{\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{d} }} $$. The bi-orthogonality of the residuals is guaranteed by forming them such that

(10.122)

and the bi-conjugacy of the search directions is fulfilled by requiring that

(10.123)

Moreover, the sequences of residuals and search directions are constructed such that the ordinary form of one is orthogonal to the shadow form of the other. Mathematically this is written as

(10.124)

Several variants of the method, which has irregular convergence with the possibility of breaking down, have been developed and the algorithm described next is due to Lanczos [21, 22].

The BiCG algorithm of Lanczos can be summarized as follows:

The BiCG method necessitates a multiplication with the coefficient matrix and with its transpose at each iteration resulting in almost double the computational effort required by the CG method per iteration.

Preconditioning may also be used with the BiCG method. For the same terminology as for the preconditioned CG method, a robust variant of the method developed by Fletcher [23] is summarized next.

The preconditioned algorithm for the BiCG of Fletcher is as follows (P representing the preconditioning matrix):

Other variants of the BiCG method that are more stable and robust have been reported such as the conjugate gradient squared (CGS) method of Sonneveld [24], the bi-conjugate gradient stabilized (Bi-CGSTAB) method of Van Der Vorst [25] and the generalized minimal residual method GMRES [13, 26–29]. These methods are useful for solving large systems of equations arising in CFD applications as they are applicable to non-symmetrical matrices and to both structured and unstructured grids.

10.4 The Multigrid Approach

The rate of convergence of iterative methods drastically deteriorates as the size of the algebraic system increases, with the drop in convergence rate even observed in medium to large systems after the initial errors have been eliminated. This has constituted a severe limitation for iterative solvers. Luckily it was very quickly found that the combination of multigrid and iterative methods can practically remedy this weakness.

Developments in multigrid methods started with the work of Fedorenko [30] (Geometric Multigrid), Poussin [31] (Algebraic Multigrid), and Settari and Azziz [32], and gained more interest with the theoretical work of Brandt [33]. While high-frequency or oscillatory errors are easily eliminated with standard iterative solvers (Jacobi, Gauss-Seidel, ILU), these solution techniques cannot easily remove the smooth or low frequency error components [34]. Because of that these solution methods are denoted by smoothers in the context of multigrid methods. An illustration of error frequency is shown in Fig. 10.4 where the variations of error frequency modes for a one dimensional problem are plotted.

Fig. 10.4

Schematic of different error modes in a one dimensional grid

The error modes shown in Fig. 10.4 vary from high frequency of short wavelength $$ \lambda_{1} $$ to low frequency of long wavelength $$ \lambda_{5} $$ and are plotted collectively on the top of the figure. The one dimensional domain is discretized using the one dimensional grid shown and the various modes are separately plotted over the same grid. As can be seen, the high frequency error appears oscillatory over an element and is easily sensed by the iterative method. As the frequency of the error decreases or as the wavelength $$ (\lambda) $$ increases, the error becomes increasingly smoother over the grid as only a small portion of the wavelength lies within any cell. This gets worse as the grid is further refined, leading to a higher number of equations and explaining the degradation in the rate of convergence as the size of the system increases.

Multigrid methods improve the efficiency of iterative solvers by ensuring that the resulting low frequency errors that arise from the application of a smoother at any one grid level are transformed into higher frequency errors at a coarser grid level. By using a hierarchy of coarse grids (Fig. 10.5), multigrid methods are able to overcome the convergence degradation.

Fig. 10.5

A schematic of the hierarchy of grid systems used with the multi grid approach

Generally the coarse mesh can be formed using either the topology and geometry of the finer mesh, this is akin to generating a new mesh for each coarse level on top of the finer level mesh or by direct agglomeration of the finer mesh elements [35–40]; this approach is also known as the Algebraic MultiGrid Method (AMG). In the AMG no geometric information is directly needed or used, and the agglomeration process is purely algebraic, with the equations at each coarse level reconstructed from those of the finer level, again through the agglomeration process. This approach can be used to build highly efficient and robust linear solvers for both highly anisotropic grids and/or problems with large changes in the coefficients of their equations.

In either approach, a multigrid cycling procedure is used to guide the traversal of the various grid hierarchies. Each traversal from a fine grid to a coarse one involves: (i) a restriction procedure, (ii) the setup or update of the system of equations for the coarse grid level, and (iii) the application of a number of smoother iterations. A traversal from a coarse grid to a finer one requires: (i) a prolongation procedure, (ii) the correction of the field values at the finer level, and (iii) the application of a number of smoother iterations on the equations constructed during restriction. The various steps needed are detailed next.

10.4.1 Element Agglomeration/Coarsening

The first step in the solution process is to generate the coarse/fine grid levels by an agglomeration/coarsening algorithm. Three different approaches can be adopted for that purpose. In the first approach, the coarse mesh is initially generated and the fine levels are obtained by refinement [41, 42]. This facilitates the definitions of the coarse-fine grid relations and is attractive in an adaptive grid setup [41–43]. A major drawback however, is the dependence of the fine grid distribution on the coarse grid. In the second method, non-nested grids are used [44] rendering the transfer of information between grid levels very expensive. In addition, both approaches do not allow good resolution of complex domains. In the third approach, recommended here, the process starts with the generation of the finest mesh that will be used in solving the problem. Then coarse grid levels are developed through agglomeration of the fine-grid elements [45, 46], as shown in Fig. 10.6, with the agglomeration process based either on the elements geometry or on a criterion to be satisfied by the coefficients of neighboring elements. The discussions to follow are pertinent to the third approach.

Fig. 10.6

Agglomeration of a fine grid level to form a coarse grid level

Coarse grid levels are generated by fusing fine grid elements through an agglomeration algorithm. For each coarse grid level, the algorithm is repeatedly applied until all grid cells of the finer level become associated with coarse grid cells. During this heuristic agglomeration process, fine grid points are individually visited. A cell is selected as the seed element into which a certain number of neighboring elements satisfying the set criteria are fused to form a coarse element. The maximum number of fine elements to be fused into a coarse element is decided a priori. If the chosen seed element fails to form a coarse element, it is added to the least populated coarse element among its neighbors.

An efficient agglomeration algorithm is the directional agglomeration (DA) algorithm developed by Mavriplis [47]. In the DA, agglomeration is performed by starting with a seed element and merging with it the neighboring fine grid elements based on the strength of their geometric connectivity. The procedure needs to be performed only once at the start of the solution.

10.4.2 The Restriction Step and Coarse Level Coefficients

The solution starts at the fine grid level. After performing few iterations, the error is transferred or restricted to a coarser grid level and the solution is found at that level. Then after performing few iterations at that level the error is restricted again to a higher level and the sequence of events repeated until the highest or coarsest grid level is reached. Let $$ \left( k \right) $$ denotes some level at which the solution has been found by solving the following system of equations in correction form:

(10.125)

The next coarser level is $$ \left( {k + 1} \right) $$ to which the error will be restricted. Let $$ G_{I} $$ represents the set of cells i on the fine grid level $$ \left( k \right) $$ that are agglomerated to form cell I of the coarse grid level $$ \left( {k + 1} \right) $$. Then, the system to be solved on the coarse grid at level $$ \left( {k + 1} \right) $$ is

(10.126)

with the residuals on the RHS of Eq. (10.126) computed as

(10.127)

where $$ I_{k}^{k + 1} $$ is the restriction operator (i.e., the interpolation matrix) from the fine grid to the coarse grid as defined by the agglomeration process. In AMG the restriction operator is defined in a linear manner to yield a summation of the fine grid residuals as

(10.128)

Moreover, the coefficients of the coarse element are constructed by adding the appropriate coefficients of the constituting fine elements. Recalling that a linear equation after discretization has the form

(10.129)

which, for the current purpose, is written for the fine grid level in a more suitable form as

(10.130)

where $$ NB\left( i \right) $$ refers to the neighbors of element i. Initially Eq. (10.130) is not satisfied resulting in the following residual:

(10.131)

Denoting by $$ \phi_{I}^{{\left( {k + 1} \right)}} $$ the solution on the coarse mesh element I that is parent to the fine mesh element i, the correction on the fine mesh from the coarse mesh can be written as

(10.132)

It is desired for the correction to result in zero residuals over the coarse mesh element I. These new residuals denoted by $$ \tilde{r}_{i}^{\left( k \right)} $$ are calculated as

(10.133)

or equivalently as

(10.134)

Enforcing the residual sum in I to zero, i.e.,

(10.135)

and substituting Eq. (10.134) in Eq. (10.135) yields

(10.136)

Rewriting Eq. (10.136) using coarse mesh numbering, the coarse mesh correction equation becomes

(10.137)

where $$ a_{I}^{{\left( {k + 1} \right)}} ,a_{IJ}^{{\left( {k + 1} \right)}} ,\;{\text{and}}\;r_{I}^{{\left( {k + 1} \right)}} $$ are derived directly from fine grid coefficients as

(10.138)

This is illustrated in Fig. 10.7.

Fig. 10.7

The restriction step and assembly of coarse grid level coefficients

10.4.3 The Prolongation Step and Fine Grid Level Corrections

The prolongation operator is used to transfer the correction from a coarse to a fine grid level. Many options may be used. One possibility, depicted in Fig. 10.8, is a zero order prolongation operator that yields the same value of the error on the fine grid, i.e., the error at a coarse grid cell will be inherited by all the children of this cell on the fine grid level.

Fig. 10.8

The prolongation step and fine grid level corrections

The correction is basically obtained from the solution of the system of equations at the coarse grid. The interpolation or prolongation to the fine grid level is denote as

(10.139)

where $$ I_{k + 1}^{k} $$ is an interpolation matrix from the coarse grid to the fine grid. Finally, the fine grid solution is corrected as

(10.140)

The number of grid levels used depends on the size of the grid. For a larger number of grid levels, the procedure is the same as sketched in Fig. 10.8.

10.4.4 Traversal Strategies and Algebraic Multigrid Cycles

Traversal strategies refer to the way by which coarse grids are visited during the solution process, which are also known as multigrid cycles [48]. The usual cycles used in the AMG method are the V cycle, the W cycle, and the F cycle [35, 36, 49, 50] displayed in Fig. 10.9.

Fig. 10.9

a V, b W, and c F multigrid cycles

The simplest AMG cycle, illustrated in Fig. 10.9a, is the V cycle [49, 50] and consists of visiting each of the grid levels only once. The usual practice is to perform few iterative sweeps in the restriction phase and then to inject the residual to a coarser grid until reaching the coarsest level. For very stiff systems, the V cycle may not be sufficient for accelerating the solution and therefore, more iterations on the coarse level are required. The W cycle is based on applying smaller V cycles on each visited coarse grid level. In this manner, the W cycle (Fig. 10.9b) consists of nested coarse and fine grid level sweeps with the complexity increasing as the number of AMG levels increases. The F cycle is a variant of the W cycle and can be thought of as splitting the W cycle in half as shown in Fig. 10.9c. The F cycle requires less coarse level sweeps than the W cycle but more sweeps than the V cycle. Therefore, it lies in between the V and W cycling strategies.

10.5 Computational Pointers

10.5.1 uFVM

In uFVM, two linear algebraic solvers are implemented. The successive over-relaxation method (SOR) and the ILU(0) method. The implementation of these methods follows the procedures described earlier. The SOR is located in the file “cfdSORSolver.m” while the ILU(0) implementation can be found in “cfdILUSolver.m”.

10.5.2 OpenFOAM®

The organizational structure of iterative linear algebraic solvers in OpenFOAM® [51] follows the usual approach. It starts by defining the base classes from which each type of algebraic matrix solvers is established. These algebraic solvers are grouped under three main categories denoted by solvers, preconditioners, and smoothers. Smoothers and preconditioners are differentiated by relating to smoothers the fixed point relation and embedding them within the preconditioners framework. Recalling Eq. (10.81), the preconditioners classes implement the product $$ {\mathbf{P}}^{ - 1} {\mathbf{r}} $$ while the smoothers classes advance the solution. Moreover, the solvers category collects the necessary information related to the implementation of the conjugate gradient and multigrid algorithms.

The source codes of the linear algebraic solvers reside within the lduMatrix folder located at “…/src/OpenFOAM/matrices/lduMatrix/” in the following three subfolders:

solvers

preconditioners

smoothers

The name of each subfolder reflects its functionality. The folder solvers contains the main codes of the iterative solvers implemented in OpenFOAM®, which are

diagonalSolver: a diagonal solver for both symmetric and asymmetric problems.

GAMG: a geometric agglomerated algebraic multigrid solver (also named Generalized geometric- algebraic multi-grid in the manual).

ICC: an incomplete Cholesky preconditioned conjugate gradient solver.

PBiCG: a preconditioned bi-conjugate gradient solver for asymmetric matrices.

PCG: a preconditioned conjugate gradient solver for symmetric matrices.

smoothSolver: an iterative solver using smoother for symmetric and asymmetric matrices based on preconditioners.

The folder preconditioners contains various implementations of the diagonal ILU denoted by

diagonalPreconditioner: a diagonal preconditioner.

DICPreconditioner, DILUPreconditioner: a diagonal Incomplete Cholesky preconditioner for symmetric and asymmetric matrices respectively.

FDICPreconditioner: a faster version of the DICPreconditioners diagonal-based incomplete Cholesky preconditioner for symmetric matrices in which the reciprocal of the preconditioned diagonal and the upper coefficients divided by the diagonal are calculated and stored.

GAMGPreconditioner: geometric agglomerated algebraic multigrid preconditioner. It uses a mutigrid cycle as preconditioner to execute the second part of Eq. (10.81).

noPreconditioner: a null preconditioner for both symmetric and asymmetric matrices.

Finally the smoothers folder contains the following:

DIC, DILU: a diagonal-based incomplete Cholesky smoother for symmetric and asymmetric matrices.

DICGaussSeidel, DILUGaussSeidel: a combined DIC, DILU/Gauss-Seidel smoother for symmetric and asymmetric matrices in which DIC, DILU smoothing is followed by Gauss-Seidel to ensure that any “spikes” created by the DIC, DILU sweeps are smoothed out.

DILU: a diagonal-based incomplete LU smoother for asymmetric matrices.

GaussSeidel: The Gauss-Seidel method for both symmetric and asymmetric matrices.

Furthermore OpenFOAM® defines inside the lduMatrix class three additional base classes that wrap the three corresponding categories. Thus the lduMatrix.H file reads (Listing 10.1)

Listing 10.1

The three base classes (solver, smoother, and preconditioner) defined with the lduMatrix class

So each smoother, solver, and preconditioner has to be derived from these three base classes. For example, the DILU preconditioner is declared as shown in Listing 10.2,

Listing 10.2

Syntax used to declare the DILU preconditioner

while the Conjugate Gradient solver is declared as shown in Listing 10.3.

Listing 10.3

Syntax used to declare the PCG solver

In either case the preconditioner or the solver is evidently derived from the base class defined under the lduMatrix class.

Having clarified the basic concepts and organizational structure of algebraic solvers in OpenFOAM®, an example investigating the details of implementing the preconditioned CG method is now provided. The files are located in the directory “$FOAM_SRC/OpenFOAM/matrices/lduMatrix/solvers/PCG”.

The class derived from the lduMatrix::solver class, as shown in Listing 10.3, defines the main member function “solve” using the script in Listing 10.4.

Listing 10.4

Script used to define the member function “solve”

The function “solve” implements the solution algorithm of the chosen linear algebraic solver in file “PCG.C”. Recalling the preconditioned conjugate gradient algorithm, its sequence of events are given by

1.

Calculate $$ {\mathbf{r}}^{\left( 0 \right)} = {\mathbf{b}} - {\mathbf{A}}{\varvec{\upphi}}^{\left( 0 \right)} $$

2.

Calculate $$ {\mathbf{d}}^{\left( 0 \right)} = {\mathbf{P}}^{ - 1} {\mathbf{r}}^{\left( 0 \right)} $$

3.

Calculate

4.

Calculate $$ {\varvec{\upphi}}^{{\left( {n + 1} \right)}} = {\varvec{\upphi}}^{\left( n \right)} + \alpha^{\left( n \right)} {\mathbf{d}}^{\left( n \right)} $$

5.

Calculate $$ {\mathbf{r}}^{{\left( {n + 1} \right)}} = {\mathbf{r}}^{\left( n \right)} - \alpha^{\left( n \right)} {\mathbf{Ad}}^{\left( n \right)} $$

6.

If solution has converged stop

7.

Calculate

8.

Calculate $$ {\mathbf{d}}^{{\left( {n + 1} \right)}} = {\mathbf{P}}^{ - 1} {\mathbf{r}}^{{\left( {n + 1} \right)}} + \beta^{{\left( {n + 1} \right)}} {\mathbf{d}}^{\left( n \right)} $$

9.

Go to step 3

The algorithm is directly implemented in “PCG.C” following the same procedure as described next.

In step 1, depicted in Listing 10.5, the residual is evaluated and stored in the rA variable while the wA variable stores the matrix-solution product $$ {\mathbf{A}}{\varvec{\upphi}}^{\left( 0 \right)} $$.

Listing 10.5

Script used to calculate the residuals

Step 2 involves preconditioning. Thus, first the type of preconditioner used is defined with the object preconPtr as (Listing 10.6).

Listing 10.6

Defining the type of preconditioner used

The constructor used is a generic one based on the base class and the “New” constructor. The preconditioner type is chosen from the dictionary at run time. Then the preconditioning operation, $$ {\mathbf{P}}^{ - 1} {\mathbf{r}}^{\left( n \right)} $$, is applied to the residual rA (according to the equation in step 2 of the algorithm). The result is stored in the same variable wA to reduce memory usage and then used in the evaluation of $$ \left( {{\mathbf{r}}^{\left( n \right)} } \right)^{\text{T}} {\mathbf{P}}^{ - 1} {\mathbf{r}}^{\left( n \right)} $$ by simply performing the scalar product of the two vectors wA and rA using the gSumProd function, as shown in Listing 10.7. Moreover the old value of wArA from the previous iteration $$ \left( {n - 1} \right) $$ is stored in the variable wArAold.

Listing 10.7

Syntax used to calculate $$ \left( {{\mathbf{r}}^{\left( n \right)} } \right)^{\text{T}} {\mathbf{P}}^{ - 1} {\mathbf{r}}^{\left( n \right)} $$ and to store its old value

Following the preconditioned conjugate gradient algorithm, steps 3, 4, and 5 are performed as displayed in Listing 10.8.

Listing 10.8

Script used to calculate $$ \alpha $$ and to update the values of the dependent variable and the residuals

Now the variable wA stores the product $$ {\mathbf{Ad}}^{\left( n \right)} $$ while pA represents the $$ {\mathbf{d}}^{\left( n \right)} $$ vector. Again the product $$ \left( {{\mathbf{d}}^{\left( n \right)} } \right)^{\text{T}} {\mathbf{Ad}}^{\left( n \right)} $$ is performed with the gSumProd function and stored in the wApA variable. Once alpha is evaluated, the update of residuals and solution of steps 4 and 5 is performed in the for loop with the variables psiPtr and rAPtr shown in Listing 10.8 representing $$ {\boldsymbol{\upphi}} $$ and $$ {\mathbf{r}} $$, respectively.

The iteration in the algorithm is completed by executing steps 7 and 8 using the script in Listing 10.9.

Listing 10.9

Script used for calculating new values for $$ \beta $$ and d to be used in the next iteration

For practical use in test cases, the definitions of the linear solver are made inside the system directory in the fvSolution under the syntax solvers {} as shown in Listing 10.10.

Listing 10.10

Definition of the linear solver

The meaning of the various entries in Listing 10.10 are

solver: defines the type of solver (in this case PCG is the preconditioned conjugate gradient for symmetric matrices), with the various options being as follows:

“PCG”: preconditioned conjugate gradient (for symmetric matrices only).

“PBiCG”: preconditioned biconjugate gradient (for asymmetric matrices only).

“smoothSolver”: solver used only as a smoother to reduce residuals.

“GAMG”: generalised geometric algebraic multigrid. It should be used for the pressure equation on large grids.

preconditioner: defines the type of the preconditioner to be used. The two available options are

“DIC”: diagonal incomplete-cholesky preconditioner for symmetric matrices.

“DILU”: diagonal incomplete-lower-upper preconditioner for asymmetric matrices.

tolerance: the maximum allowable value of the absolute residual for the linear solver to stop iterating.

relTol: the ratio between the initial residual and the actual residual for the linear solver to stop iterating.

Other examples are shown in Listing 10.11.

Listing 10.11

Examples of defining the linear solver

10.6 Closure

The chapter introduced the direct and iterative approaches for solving algebraic systems of equations. In each category a number of methods were described. The algebraic multigrid technique was also discussed. The next chapter will proceed with the discretization of the conservation equation and will detail the discretization of the convection term.

10.7 Exercises

Exercise 1

In each of the following cases obtain the LU factorization of matrix A and use it to solve the system of equation Ax = b by performing the backward and forward substitution, i.e., Ly = b, Ux = y:

(a)

(b)

(c)

Exercise 2

Using the Gauss-Seidel and Jacobi methods and starting with a zero initial guess solve the following systems of equations while adopting as a stopping criteria $$ \hbox{max} \left( {\left\| {{\mathbf{Ax}} - {\mathbf{b}}} \right\|} \right) < 0.1 $$:

(a)

(b)

(c)

Exercise 3

For the systems of equations in Exercise 2 find the preconditioned matrix P for both the Gauss-Seidel and Jacobi methods. Use Eq. (10.81) with a zero initial guess to resolve the systems of equations subject to the same stopping criteria. Compare solutions with those obtained in Exercise 2.

Exercise 4

Perform the ILU(0) factorization of the following M matrices:

(a)

(b)

(c)

Exercise 5

Based on the factorizations in Exercise 4 and knowing that the lower and upper parts of the factorization correspond to $$ {\overline{\mathbf{L}}} $$ and $$ {\overline{\mathbf{U}}} $$, respectively, find for each of the cases the error matrix defined as R = M − P.

Exercise 6

Perform the DILU factorization of the following M matrices:

(a)

(b)

(c)

Exercise 7

Based on the diagonal factorizations in exercise 6 and using Eq. (10.91), find for each of the cases the error matrix defined as R = M − P.

Exercise 8

Solve the following systems of equations using the ILU(0) and DILU methods. Perform three iterations only starting with a zero initial guess.

(a)

(b)

Exercise 9

Solve the systems of equations in Exercise 8 using the Gauss-Seidel and Jacobi methods (starting with a zero initial guess) and compare the errors after three iterations with the errors obtained in exercise 8 and with the exact solution. Comment on the results.

Exercise 10

Solve the following symmetric systems of equations by performing two iterations of the preconditioned conjugate gradient method (start with a zero field):

(a)

(b)

(c)

Exercise 11

List all the available linear solvers inside OpenFOAM®.

After choosing the smoothSolver in OpenFOAM®, list all implemented smoothers.

Exercise 12

Find in OpenFOAM® the implementation of the BiCG linear solver (PBiCG) and compare it with the BiCG algorithm of Lanczos.

Exercise 13

Find in OpenFOAM® the implementation of the multigrid V-cycle ($FOAM_SRC/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C) and compare it with the theoretical V-cycle algorithm.

Exercise 14

Verify the correct implementation in OpenFOAM® of the diagonal version of the ILU(0) developed by Pommerell.

References

1.

Duff I, Erisman A, Reid J (1986) Direct methods for sparse matrices. Clarendon Press, OxfordMATH

2.

Westlake JR (1968) A handbook of numerical matrix inversion and solution of linear equations. Wiley, New YorkMATH

3.

Stoer J, Bulirsch R (1980) Introduction to numerical analysis. Springer, New YorkCrossRef

4.

Press WH (2007) Numerical recipes, 3rd edn. The art of scientific computing. Cambridge University Press, Cambridge

5.

Thomas LH (1949) Elliptic problems in linear differential equations over a network. Watson Sci. Comput. Lab Report, Columbia University, New York

6.

Conte SD, deBoor C (1972) Elementary numerical analysis. McGraw-Hill, New YorkMATH

7.

Pozrikidis C (1998) Numerical computation in science and engineering. Oxford University Press, Oxford

8.

Sebben S, Baliga BR (1995) Some extensions of tridiagonal and pentadiagonal matrix algorithms. Numer Heat Transfer, Part B, 28:323–351

9.

Zhao X-L, Huang T-Z (2008) On the inverse of a general pentadiagonal matrix. Appl Math Comput 202(2):639–646MATHMathSciNetCrossRef

10.

Karawia AA (2010) Two algorithms for solving general backward pentadiagonal linear systems. Int J Comput Math 87(12):2823–2830MATHMathSciNetCrossRef

11.

Hageman L, Young D (1981) Applied iterative methods. Academic Press, New YorkMATH

12.

Saad Y (2003) Iterative methods for sparse linear systems, 2nd edn. Society for Industrial and Applied Mathematics

13.

Golub G, Van Loan C (2012) Matrix computations, 4th edn. The Johns Hopkins University Press, Baltimore

14.

Dongarra J, Van Der Vorst H (1993) Performance of various computers using standard sparse linear equations solving techniques. In: Computer benchmarks. Elsevier Science Publishers BV, New York, pp 177–188

15.

Van Der Vorst H (1981) Iterative solution methods for certain sparse linear systems with a nonsymmetric matrix arising from PDEProblems. J Comput Phys 44:1–19MATHMathSciNetCrossRef

16.

Meijerink J, Van Der Vorst H (1977) An iterative solution method for linear systems of which the coefficient matrix is a symmetric M matrix. Math Comput 31:148–162MATH

17.

Beauwens R, Quenon L (1976) Existence criteria for partial matrix factorizations in iterative methods. SIAM J Numer Anal 13:615–643MATHMathSciNetCrossRef

18.

Pommerell C (1992) Solution of large unsymmetric systems of linear equations. PhD thesis, Swiss Federal Institute of Technology, Zurich, Switzerland

19.

Van Der Sluis A, Van Der Vorst H (1986) The rate of convergence of conjugate gradients. Numer Math 48(5):543–560MATHMathSciNetCrossRef

20.

Faber V, Manteuffel T (1984) Necessary and sufficient conditions for the existence of a conjugate gradient method. SIAM J Numer Anal 21:315–339MathSciNetCrossRef

21.

Lanczos C (1950) An iteration method for the solution of eigenvalue problem of linear differential and integral operators. J Res Natl Bur Stand 45:255–282 (RP 2133)MathSciNetCrossRef

22.

Lanczos C (1952) Solution of systems of linear equations by minimized iterations. J Res Natl Bur Stand 49(1):33–53 (RP 2341)

23.

Fletcher R (1976) Conjugate gradient methods for indefinite systems. In: Watson G (ed) Numerical analysis Dundee 1975. Springer, Berlin, pp 73–89

24.

Sonneveld P (1989) CGS, AFast Lanczostype solver for nonsymmetric linear systems. SIAM J Sci Stat Comput 10:36–52MATHMathSciNetCrossRef

25.

Van Der Vorst H (1992) BiCGSTAB: a fast and smoothly converging variant of BiCG for the solution of nonsymmetric linear systems. SIAM J Sci Stat Comput 13:631–644MATHCrossRef

26.

Van Der Vorst H, Vuik C (1991) GMRESR: a family of nested GMRES methods. Technical report 9180, Delft University of Technology, Faculty of Tech. Math, Delft, The Netherlands

27.

Southwell R (1946) Relaxation methods in theoretical physics. Clarendon Press, Oxford

28.

Demmel J, Heath M, Van Der Vorst H (1993) Parallel numerical linear algebra. Acta Numerica 2:111–198

29.

Saad Y, Schultz M (1986) A generalized minimal residual algorithm for solving nonsymmetric linear systems. SIAM J Sci Stat Comput 7:856–869MATHMathSciNetCrossRef

30.

Fedorenko P (1962) A relaxation method for solving elliptic difference equations. USSR Comput Math Math Phys 1(4):1092–1096CrossRef

31.

Poussin FV (1968) An accelerated relaxation algorithm for iterative solution of elliptic equations. SIAM J Numer Anal 5:340–351MATHMathSciNetCrossRef

32.

Settari A, Aziz K (1973) A generalization of the additive correction methods for the iterative solution of matrix equations. SIAM J Numer Anal 10(3):506–521MATHMathSciNetCrossRef

33.

Brandt A (1977) Multi-level adaptive solutions to boundary value problems. Math Comput 31(138):333–390MATHCrossRef

34.

Briggs WL (1987) A multigrid tutorial. Society of Industrial and Applied Mathematics, Philadelphia, PAMATH

35.

Shome B (2006) An enhanced additive correction multigrid method. Numer Heat Transfer B 49:395–407

36.

Hutchinson BR, Raithby GD (1986) A multigrid method based on the additive correction strategy. Numer Heat Transfer 9:511–537CrossRef

37.

Elias SR, Stubley GD, Raithby GD (1997) An adaptive agglomeration method for additive correction multigrid. Int J Numer Meth Eng 40:887–903MATHCrossRef

38.

Mavriplis D, Venkatakfrishnan V (1994) Agglomeration multigrid for viscous turbulent flows. AIAA paper 94-2332

39.

Phillips RE, Schmidt FW (1985) A multilevel-multigrid technique for recirculating flows. Numer Heat Transfer 8:573–594MATH

40.

Lonsdale RD (1991) An algebraic multigrid scheme for solving the Navier-Stokes equations on unstructured meshes. In: Taylor C, Chin JH, Homsy GM (eds) Numerical methods in laminar and turbulent flow, vol 7(2). Pineridge Press, Swansea, pp 1432–1442

41.

Perez E (1985) A 3D finite element multigrid solver for the euler equations. INRIA report 442

42.

Connell SD, Braaten DG (1994) A 3D unstructured adaptive multigrid scheme for the Euler equations. AIAA J 32:1626–1632MATHCrossRef

43.

Parthasarathy V, Kallinderis Y (1994) New multigrid approach for three-dimensional unstructured adaptive grids. AIAA J 32:956–963MATHCrossRef

44.

Mavriplis DJ (1995) Three-dimensional multigrid reynolds-averaged Navier-Stokes solver for unstructured meshes. AIAA J 33(12):445–453MATHCrossRef

45.

Qinghua W, Yogendra J (2006) Algebraic multigrid preconditioned Krylov subspace methods for fluid flow and heat transfer on unstructured meshes. Numer Heat Transfer B 49:197–221CrossRef

46.

Lallemand M, Steve H, Dervieux A (1992) Unstructured multigridding by volume agglomeration: current status. Comput Fluids 21:397–433MATHCrossRef

47.

Mavriplis DJ (1999) Directional agglomeration multigrid techniques for high Reynolds Number viscous flow solvers. AIAA J 37:393–415CrossRef

48.

Trottenberg U, Oosterlee C, Schüller A (2001) Multigrid. Academic Press, LondonMATH

49.

Phillips RE, Schmidt FW (1985) Multigrid techniques for the solution of the passive scalar advection-diffusion equation. Numer Heat Transfer 8:25–43MATH

50.

Ruge JW, Stüben K (1987) Algebraic multigrid (AMG). In: McCormick SF (ed) Multigrid methods, frontiers in applied mathematics, vol 3. SIAM, Philadelphia, pp 73–130

51.

OpenFOAM, 2015 Version 2.3.x. http://​www.​openfoam.​org

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_11

11. Discretization of the Convection Term

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

So far, the discretization of the general steady diffusion equation has been formulated on orthogonal, non-orthogonal, structured, and unstructured grids. Another important term, the convection term represented by the divergence operator, is the focus of this chapter. Initially this term is discretized using a symmetrical linear profile similar to the one adopted for the discretization of the diffusion term. The shortcomings of this profile are delineated and a remedy is suggested through the use of an upwind profile. Even though it leads to physically plausible predictions, the upwind profile is shown to be highly diffusive generating results that are first order accurate. To increase accuracy, higher order profiles that are upwind biased are introduced. While reducing the discretization error, higher order profiles are shown to give rise to another type of error known as the dispersion error. Methods dealing with this error will be dealt with in the next chapter. Moreover, the flow field, which represents the driving catalyst of the convection term, is assumed to be known. The computation of the flow field will be the subject of later chapters.

11.1 Introduction

Although the convection term looks simple, its discretization presents a number of difficulties that have occupied researchers for more than three decades now. Their work has shed light on the problems that hindered its discretization and resulted in the development of a large number of convection schemes. The body of literature is so large that two chapters are devoted for the analysis of this term. In this chapter the basic concepts are introduced and High Order (HO) [1–3] upwind biased schemes are discussed. The bounding of the convective flux, which made possible the development of non-oscillatory convection schemes of high order of accuracy, denoted by High Resolution (HR) schemes, will be discussed in the next chapter.

For clarity, the presentation of new concepts will be initially introduced using a one dimensional grid, and then extended to multi dimensional non-orthogonal grids. The chapter starts with the discretization of the one-dimensional convection-diffusion problem to highlight, through a stability criterion, the shortcomings of the central difference scheme [4, 5]. The upwind scheme [6] is shown to pass the stability test. The numerical diffusion error associated with low order schemes and the numerical dispersion error accompanying high order schemes are also explained. The treatment of the class of HR schemes will be discussed in the next chapter.

11.2 Steady One Dimensional Convection and Diffusion

Initially the derivations are performed for a very simple, one dimensional, steady convection-diffusion problem to learn as much as possible without being distracted by the complexity of the calculations. The governing equation for the case studied can be written as

(11.1)

Luckily an analytical solution for the problem is available, and is used as a reference with which various numerical solutions are compared.

11.2.1 Analytical Solution

The continuity equation for this steady-state one dimensional problem of constant cross sectional area is given by

(11.2)

implying that ρu is constant. Having this in mind and integrating with respect to x, Eq. (11.1) becomes

(11.3)

where c ₁ is a constant of integration the value of which depends on the boundary conditions used. Rearranging, Eq. (11.3) is rewritten as

(11.4)

Through a change of variable, Eq. (11.4) is transformed to

(11.5)

where

(11.6)

Separating variables and integrating, the solution to Eq. (11.5) is found to be

(11.7)

where $$ c_{2} $$ is another constant of integration. Reverting back to the original variable, the general solution for $$ \phi $$ is given by

(11.8)

Thus the analytical solution between the two points W and E shown in Fig. 11.1 and subject to

(11.9)

is obtained as

(11.10)

where $$ Pe_{L} $$ is the Péclet number (based on the length L), which represents the ratio of the advective transport rate of $$ \phi $$ to its diffusive transport rate, and is given by

(11.11)

Equation (11.10) is evaluated for different values of $$ Pe_{L} $$ and results are displayed in Fig. 11.2. As shown, variations in $$ \phi $$ between W and E change from a linear profile for pure diffusion problems to almost a step profile at high values of $$ Pe_{L} $$.

Fig. 11.1

Notation for a one dimensional grid system

Fig. 11.2

Analytical solutions of the one dimensional convection and diffusion problem for various $$ Pe_{L} $$

11.2.2 Numerical Solution

The discretization of Eq. (11.1) starts by integrating the conservation equation over the one dimensional element shown in Fig. 11.1 to yield

(11.12)

where v = u i is the velocity vector. The conservation equation can be written in terms of the convection and diffusion fluxes as

(11.13)

Then, using the divergence theorem, the volume integral is transformed into a surface integral giving

(11.14)

Replacing the surface integral by a summation of fluxes over the element faces, Eq. (11.14) becomes

(11.15)

Noting that the surface vectors on opposite sides of the element have opposite signs, the expanded form of Eq. (11.15) for a constant cross section is obtained as

(11.16)

The values of u at the cell faces are known, and those of the gradient can be discretized in the way previously described. The question is how to proceed in the discretization of the face values $$ \phi_{e} $$ and $$ \phi_{w} $$ in terms of the values at adjacent nodes. The method of specifying these face values is denoted in the literature by the “advection scheme”.

11.2.3 A Preliminary Derivation: The Central Difference (CD) Scheme

At first sight the “obvious” answer would be a linear interpolation profile similar to the one used for the diffusion term. Hence, the value of $$ \phi $$ at a given face, say the right face e, will be computed as

(11.17)

where k 0 and k 1 are constants evaluated using the two nodes straddling face e. Thus using the fact that $$ \phi = \phi_{E} $$ at $$ x = x_{E} $$ and $$ \phi = \phi_{C} $$ at $$ x = x_{C} $$, Eq. (11.17) evaluated at $$ x = x_{e} $$ gives

(11.18)

This is basically the central difference scheme that can be obtained by a Taylor series expansion where terms involving derivatives of the second order and higher are neglected, which means it is second order accurate.

For the uniform grid shown in Fig. 11.3, Eq. (11.18) becomes

(11.19)

Fig. 11.3

The Central Difference scheme profile

Example 1

Derive the value of $$ \phi_{e} $$ for a central difference scheme using a Taylor expansion approach

Solution

The Taylor expansion about e can be written as

thus

for a uniform grid $$ \delta x_{e} =\Delta x_{C} $$ yielding

Thus after the discretization of the diffusion term using a linear profile (Fig. 11.3), the term in the first square bracket of Eq. (11.16) becomes

(11.20)

where

(11.21)

A similar expression for the term in the second square bracket of Eq. (11.16) can also be derived and is given by

(11.22)

where now

(11.23)

Substitution of these values into the convection-diffusion equation yields

(11.24)

where

(11.25)

As the problem is one dimensional $$ \Delta y_{e} =\Delta y_{w} $$ and, without loss of generality, can be set equal to 1. Moreover, from continuity u is constant and thus $$ \left( {\rho u\Delta y} \right)_{e} - \left( {\rho u\Delta y} \right)_{w} = 0 $$. Assuming a uniform diffusion coefficient, the coefficients of the discretized equation can be simplified to

(11.26)

Substituting back in Eq. (11.24), the value for $$ \phi_{C} $$ is found as

(11.27)

If the grid is assumed to be uniform, then the above equation can be written in terms of Pe L as

(11.28)

where L is $$ \left( {x_{E} - x_{W} } \right) $$, which is the size of two elements. The analytical solution for the problem can be obtained from Eq. (11.10) by setting $$ \left( {x - x_{W} } \right)/L $$ to 0.5 and is given by

(11.29)

The two solutions are compared in Fig. 11.4 as $$ Pe_{L} $$ varies from −10 to +10.Figure 11.4 demonstrates that at low values of $$ Pe_{L} $$ the numerical and analytical solutions are very close to each other. However as $$ Pe_{L} $$ is increased beyond a certain value the central difference (CD) numerical solution greatly departs from the analytical solution and becomes unbounded experiencing unphysical behavior. Whereas the analytical solution approaches asymptotically the values 0 and 1 for positive and negative values of $$ Pe_{L} $$, respectively, the CD solution decreases linearly from +∞ to −∞ as $$ Pe_{L} $$ increases from −∞ to +∞. This solution indicates that some of the assumptions used in the discretization of the equation are unrealistic or unphysical. What is the reason for this behavior?

Fig. 11.4

Comparison of numerical (obtained with the CD scheme) and analytical solutions for the one dimensional convection and diffusion problem

As depicted in Fig. 11.5, whereas diffusion at point C is equally affected by conditions upstream and downstream of C (Fig. 11.5a), the advection process is a highly directional process transporting properties only in the direction of the flow (Fig. 11.5b). Therefore the linear profile approximation, which assigns equal weight to both the upwind and downwind nodes, is a good approximation for the diffusion term (Fig. 11.5a). However it cannot describe the directional preference of convection, for which a step profile is more appropriate (Fig. 11.5b), and is the cause of the problem.

Fig. 11.5

Zone of influence of a diffusion, b convection, and c combined convection and diffusion terms and expected problem solution

The combined convection-diffusion zone of influence and the more relevant profile in this case is schematically depicted in Fig. 11.5c. This zone of influence approaches the diffusion region displayed in Fig. 11.5a and the advection region depicted in Fig. 11.5b at low and high values of the Péclet number, respectively. Therefore, as long as diffusion is the dominant transfer mechanism, the use of a linear profile yields physical results. However, once convection overwhelms diffusion, unphysical results are obtained. The value of Péclet number at which this occurs can be easily calculated. Assuming the flow to be in the positive x direction, it is noted that there is a possibility for the a E coefficient to become positive, thus leading to unphysical results (if the flow is in the negative x direction, then a W may become positive) when,

(11.30)

Defining the cell Péclet number as

(11.31)

which, for a uniform grid, is half $$ Pe_{L} $$, then Eq. (11.30) can be rewritten as

(11.32)

Thus for a cell Péclet number (Pe) larger than 2 the discretization process becomes inconsistent as now an increase in the neighboring value will lead to a decrease in the value at C. This in turn will lead to a further increase in the neighboring value, and the error is magnified.

This situation can be avoided by decreasing the grid size so that the cell Péclet number is smaller than 2. For many practical situations, however, the increase in storage and computational requirements may be too large to afford. Moreover for purely convected flows (e.g., Euler flows) this is simply not feasible. Therefore a remedy is needed.

11.2.4 The Upwind Scheme

When examining the discretization procedure described above, it is noticed that the reason for obtaining these positive coefficients is because of the adopted linear symmetric profile. A linear symmetric profile gives equal weights to the two nodes sharing the face with no directional preference, which is appropriate for non-directional phenomena with an elliptic type term, such as the diffusion term. It is simply not adequate for the convection term [4].

A scheme that is more compatible with the advection process is the upwind scheme [4, 6] schematically displayed in Fig. 11.6. The upwind scheme basically mimics the basic physics of advection in that the cell face value is made dependent on the upwind nodal value, i.e., dependent on the flow direction. In this case the cell face values for the configuration displayed in Fig. 11.6 are given by

(11.33)

where $$ \dot{m}_{e} $$ and $$ \dot{m}_{w} $$ are the mass flow rates at faces e and w given by

(11.34)

Thus, the advection flux at face e can be written as

(11.35)

where

(11.36)

In Eqs. (11.35) and (11.36), the term $$ \left\| {a,b} \right\| $$ represents the maximum of a and b. Moreover, a similar relation can be derived for the advection flux at face w and is given by

(11.37)

where now

(11.38)

Denoting the contribution of the diffusion flux with a superscript Diff, then substitution into Eq. (11.15) yields

(11.39)

which can be modified into the form

(11.40)

with

(11.41)

It is easily seen that the upwind scheme yields negative neighbor coefficients, and provided continuity is satisfied, the coefficient at the main node is given by,

(11.42)

which guarantees the boundedness property.

Invoking the continuity constraint in Eq. (11.41) and assuming uniform grid and constant diffusion coefficient, the value for $$ \phi_{C} $$ in terms of $$ \phi_{E} $$ and $$ \phi_{W} $$ is obtained from Eq. (11.40) and Eq. (11.41) as

(11.43)

The $$ \phi_{C} $$ profile generated using the upwind scheme (Eq. 11.43) is compared in Fig. 11.7 with similar ones obtained analytically (Eq. 11.29) and numerically via the central difference scheme (Eq. 11.28). At low $$ Pe_{L} $$ values, profiles indicate that the upwind scheme is not as accurate as central differencing. This is expected since the upwind profile is first order accurate while the linear profile is second order accurate. At high $$ Pe_{L} $$ values, the central difference scheme is unstable as its solution is unbounded and physically incorrect. On the other hand, even though the upwind scheme is not particularly accurate, it is physically correct.

Fig. 11.6

The upwind scheme profile

Fig. 11.7

Comparison of solutions obtained analytically and numerically using the upwind and central difference schemes for the one dimensional convection and diffusion problem

Thus there appears to be a tradeoff between accuracy and stability. Using the upwind scheme, solutions are better behaved and bounded even at high Péclet numbers. This is however achieved at the cost of low accuracy. On the other hand, the second order central difference scheme becomes unstable beyond a certain value of $$ Pe_{L} $$ resulting in physically erroneous solutions. Both schemes seem to be infected by errors, one affecting accuracy while the other affecting stability. What are these errors? This will be discussed after introducing the downwind scheme.

11.2.5 The Downwind Scheme

It is interesting to see what happens if a scheme opposite to the upwind scheme is used, i.e., the downwind scheme [7, 8]. For this interpolation profile, displayed in Fig. 11.8, the value at the node on the downwind side of the interface is taken to represent the value at the interface. Thus, the values at faces e and w are calculated as

(11.44)

Using Eq. (11.44), the advection fluxes at the faces can be written as

(11.45)

Substitution of the above values in the discretization equation, Eq. (11.15), yields

(11.46)

which can be modified into the form

(11.47)

with

(11.48)

Invoking the continuity constraint in Eq. (11.48) and assuming uniform grid and constant diffusion coefficient, the value for $$ \phi_{C} $$ in terms of $$ \phi_{E} $$ and $$ \phi_{W} $$ is obtained as

(11.49)

Without plotting Eq. (11.49) it is clear that as $$ |Pe_{L} | \to 4 $$ the solution becomes completely unbounded confirming once more the analysis presented above. The downwind scheme may be beneficial when blended with other schemes to predict sharp interfaces [7, 8]. Nevertheless its introduction here will be exploited in the next section to give better insight into stability.

Fig. 11.8

The downwind scheme profile

11.3 Truncation Error: Numerical Diffusion and Anti-Diffusion

Truncation error occurs due to the approximate nature of the discretization process and is more easily analyzed for one dimensional situations on Cartesian meshes. The diffusion and anti-diffusion of the upwind, downwind, and central difference schemes are presented next.

11.3.1 The Upwind Scheme

Considering the equation discretized via the upwind scheme, the intention is to recover the integral equation while accounting for the truncation error. To do so, $$ \phi_{C} $$ and $$ \phi_{W} $$ are written as functions of $$ \phi_{e} $$ and $$ \phi_{w} $$, respectively, for the case when the flow is assumed to be in the positive x direction. In this case the upwind scheme results in

(11.50)

Thus the one dimensional convection diffusion equation discretized using the upwind scheme simplifies to

(11.51)

The one dimensional Taylor series expansion of $$ \phi_{C} $$ with respect to its value at cell face e is given by

(11.52)

and for a uniform grid as

(11.53)

A similar expression can be obtained for $$ \phi_{W} $$ and is given by

(11.54)

Truncating second order terms and higher and substituting into the advection term, the left hand side of the discretized equation becomes

(11.55)

which can be rearranged into

(11.56)

It is clear now that the equation being solved has an added component of diffusion, which is called truncation error. The value of the numerical diffusion is equal to

(11.57)

This truncation error, also known as stream wise diffusion, reduces the accuracy of the solution by altering the magnitude of the diffusion coefficient and consequently the equation to be solved. Thus the convection and diffusion equation has an effective modified value of the diffusion effects. On the other hand, this additional stream wise numerical diffusion is desirable as it stabilizes the solution by keeping it bounded and physically correct.

It is obvious that to reduce stream wise numerical diffusion a higher order approximation of the convection term is needed. However, as will be explained in a later section, this should be done in such a way that the solution remains bounded.

11.3.2 The Downwind Scheme

As with the upwind scheme, $$ \phi_{C} $$ and $$ \phi_{W} $$ are written as functions of $$ \phi_{e} $$ and $$ \phi_{w} $$, respectively, for the case when the flow is assumed to be in the positive x direction. In this case the downwind scheme results in

(11.58)

and the discretized equation becomes

(11.59)

For a uniform grid, the one dimensional Taylor series expansions of $$ \phi_{E} $$ and $$ \phi_{C} $$ with respect to their values at cell faces e and w are given by

(11.60)

Truncating second order terms and higher and substituting into the advection term, the left hand side of the discretized equation becomes

(11.61)

For this profile, numerical diffusion has a negative sign and is equal to

(11.62)

which acts at decreasing the diffusion coefficient and in effect is an anti-diffusion error. Predictions using the downwind scheme are found to cause clipping of the advected profiles. In fact solutions to the one dimensional convection-diffusion problem generated using this scheme are more oscillatory than the CD scheme.

11.3.3 The Central Difference (CD) Scheme

The truncation error for the CD scheme is a little more involved to obtain with the finite volume method as computation of the gradient requires interpolated values at the element faces and not at nodes where they are available. Assuming the velocity is known everywhere and the grid is uniform with a size of $$ \Delta x $$, the approximation is simply the one introduced in the calculation of $$ \left( {\phi_{e} - \phi_{w} } \right) $$, which can be written as

(11.63)

where $$ TE $$ refers to truncation error. To calculate this truncation error, the following Taylor series expansions with respect to the exact $$ \phi_{e} $$ and $$ \phi_{w} $$ values are needed:

(11.64)

Using these expansions, the average values at the faces are obtained as

(11.65)

Subtracting the above two terms given in Eq. (11.65), their difference is found to be

(11.66)

Further, the expanded forms of the exact $$ \phi_{e} $$ and $$ \phi_{w} $$ with respect to $$ \phi_{C} $$ are given by

(11.67)

In addition, $$ \phi_{E} $$ and $$ \phi_{W} $$ can be expanded in terms of $$ \phi_{C} $$ as

(11.68)

Using the above two sets of equations, the following is obtained:

(11.69)

Then $$ \left( {\phi^{\prime\prime}_{e} - \phi^{\prime\prime}_{w} } \right) $$ is computed as

(11.70)

Substituting back, Eq. (11.66) is transformed to

(11.71)

Dividing throughout by $$ \Delta x $$, the truncation error associated with the calculation of the gradient is obtained as

(11.72)

which indicates that the method is second order accurate.

11.4 Numerical Stability

The confusion related to truncation error (first order for the physical solution and second order for the unphysical one) has led many workers to extrapolate that since central differencing of the diffusion term is so accurate, then central differencing of the convection term should also be similarly accurate. Of course, as seen in the previous sections, central differencing of the convection term can lead to unphysical solutions. The cause for this behavior is that the central difference scheme has no inherent convective stability when applied to derivatives of odd order like the convection term.

Leonard [9] advanced the convective stability concept as an explanation to oscillation in numerical solutions generated by applying the central difference scheme to convection dominated flows. Leonard used the general one dimensional unsteady convection-diffusion equation with constant velocity given by

(11.73)

to describe this concept. When applying this equation over the element of centroid C shown in Fig. 11.9, its left hand side (LHS) represents the rate of change of $$ \phi_{C} $$ within the control cell per unit time, and its right hand side (RHS) represents the net influx across the element surface and source terms within the element that are affecting the value of $$ \phi_{C} $$. If there were numerical errors in the RHS then the value of $$ \phi_{C} $$ calculated from Eq. (11.73) would either increase or decrease depending on the scheme used in the discretization process. In an unstable scheme, a small deviation from the correct value of $$ \phi_{C} $$ gives a corresponding increase/decrease in the net influx represented by the RHS. When an iterative procedure is used as part of the solution mechanism, an increase/decrease in the net influx will further increase/decrease the value of $$ \phi_{C} $$ at each subsequent step of the iterative process. In a stable scheme this change in $$ \phi_{C} $$ due to errors in the RHS should feed back negatively into the RHS as a self correction device. Clearly, for this kind of numerical stability, the RHS should satisfy

(11.74)

indicating that the sensitivity to $$ \phi_{C} $$ of the combination of the modeled terms on the right hand side of Eq. (11.73) should be negative. In this case, an increase/decrease in $$ \phi_{C} $$ will correspond to a decrease/increase in the influx, which will in turn pushes $$ \phi_{C} $$ downward/upward towards its correct value. However, stability should not be confused with boundedness or accuracy. A stable numerical scheme could actually be unbounded giving rise to over/under shoots and oscillations/wiggles or be very diffusive and give results that are of low accuracy. The stability here refers to controlling the numerical error to remain bounded in order for it not to increase indefinitely as was the case with the central difference scheme where the normalized value of $$ \phi_{C} $$ (Fig. 11.4) was found to vary from +∞ to −∞ while varying Pe from −∞ to +∞, even though the correct value of $$ \phi_{C} $$ should vary between 1 and 0. It so happens that the upwind scheme possesses both the boundedness and stability characteristics.

Fig. 11.9

Insensitivity of CD convection term to the values of $$ {\varvec{\phi}}_{C} $$

With this in mind, the general discretized form of the RHS of Eq. (11.73) is given by

(11.75)

Thus using the central difference scheme, Eq. (11.75) becomes

(11.76)

Analyzing the central difference scheme using the above criteria, it is found that for the diffusion term the sensitivity is given by

(11.77)

which is negative since $$ \Gamma ^{\phi } $$ is positive, indicating a stable scheme. However, for the convective term the sensitivity equation gives

(11.78)

which is equal to zero for steady flows but not necessarily for unsteady flows. For unsteady situations, its value will be positive for decelerating flows. In a general flow, such regions act as wiggle sources and can easily lead to a total numerical catastrophe when the Péclet number is large enough. Even for steady flows, as its value is zero, it cannot feed back into the equation to act as a self correction device. Equation (11.78) also indicates that for steady flow the net convective flux computed with the CD scheme is independent of the value of $$ \phi_{C} $$. Therefore, as shown in Fig. 11.9, the different possible values of $$ \phi_{C} $$ will result in the same net convective flux over the element of centroid C.

With the upwind scheme, the RHS can be obtained from Eq. (11.36) as

(11.79)

The sensitivity is expected to be negative since the scheme was found to be stable for all Péclet number, indeed

(11.80)

which is negative or equal to zero for all flows. It will be equal to zero when both mass flow rates are negative, a situation that does not arise in a one dimensional situation of constant cross-sectional area. When added to the false diffusion introduced by the first order approximation, Eq. (11.80) indicates that the scheme is very stable. However, this stability is achieved at the expense of accuracy, as was demonstrated in the previous section.

For the downwind scheme the RHS is given by

(11.81)

The sensitivity is given by

(11.82)

which is always positive or equal to zero for all flows. When this is added to the anti-diffusion effects it gives a highly unstable scheme.

11.5 Higher Order Upwind Schemes

The previous sections demonstrated that both the upwind and central difference schemes have severe limitations, the former because of its poor accuracy due to numerical diffusion, and the latter because of its instability also known as numerical dispersion error. These shortcomings have provoked a great deal of research to improve the accuracy and stability of advection schemes by using higher order upwind biased interpolation profiles. These higher-order schemes aim at producing at least a second order accurate solutions, while being unconditionally stable.

To underline the conservation property which associates fluxes with cell faces, not nodes, in what follows D, C, and U will be used to denote the Downwind, Upwind, and far Upwind nodes at any particular face. In addition, DD and UU denote the nodes downstream and upstream of D and U, respectively. The corresponding values at these locations are denoted by $$ \phi_{DD}, \phi_{D} ,\phi_{C} ,\phi_{U} $$ and $$ \phi_{UU} $$, respectively. This notation is displayed graphically in Fig. 11.10 for the cases when the velocity at the face is either positive (→) or negative (←).

Fig. 11.10

A schematic showing the UU, U, C, D and DD node locations used in describing convection schemes

11.5.1 Second Order Upwind Scheme

A second order scheme, requires the use of a linear profile, as was the case with the central difference scheme. However, instead of a symmetric profile, an upwind biased stencil is used [10]. As depicted in Fig. 11.11, the linear profile is constructed by employing the $$ \phi $$ values at nodes C and U. Therefore the value at the face is actually calculated by extrapolation rather than interpolation.

Fig. 11.11

The Second Order Upwind (SOU) scheme profile

11.5.2 The Interpolation Profile

Starting with the linear profile

(11.83)

and fitting it to the nodal values at $$ x_{C} $$ and $$ x_{U} $$ where the $$ \phi $$ values are $$ \phi_{C} $$ and $$ \phi_{U} $$, respectively, the profile becomes

(11.84)

Using the above equation, the $$ \phi $$ value at face f, shown in Fig. 11.11, is given by

(11.85)

which, for a uniform grid reduces to

(11.86)

11.5.3 The Discretized Equation

Using this profile to approximate the interface values in the discretized one dimensional convection diffusion equation (Eq. 11.16), the fluxes at the faces are obtained as

(11.87)

Substitution of these fluxes in Eq. (11.16), the discretized form is transformed to

(11.88)

which can be modified into the form

(11.89)

where

(11.90)

11.5.4 Truncation Error

Following a procedure similar to the one used with the central difference scheme, the truncation error is found to be

(11.91)

indicating second order accuracy.

11.5.5 Stability Analysis

To check the stability of the SOU scheme, the discretized convective fluxes are substituted in Eq. (11.75) resulting in the following $$ RHS_{convection} $$ term:

(11.92)

The rate of change of this term with respect to $$ \phi_{C} $$ is found as

(11.93)

which is always negative indicating a stable scheme, i.e., the solution error will always remain under control. It should be kept in mind that this is true for the conditions stated in the derivations and not for the general case when the velocity is not constant.

11.5.6 The QUICK Scheme

The Quadratic Upstream Interpolation for Convective Kinematics (QUICK) scheme was developed by Leonard [2]. The method is based on interpolating the value of the dependent variable at each face of the element by using a quadratic polynomial biased toward the upstream direction, as shown in Fig. 11.12. The interpolated value is used to calculate the convective term in the governing equations for the dependent variable. The calculation of the values of the dependent variable at a cell face is detailed next.

Fig. 11.12

The QUICK scheme profile

11.5.7 The Interpolation Profile

In its original form, the QUICK scheme required the use of a general multi dimensional second degree polynomial for the calculation of the unknown variable $$ \phi $$. However it is generally sufficient to treat the flow as locally one dimensional [11] and to use a second order one dimensional profile in each coordinate direction. For the one dimensional convection-diffusion problem under discussion, the value of $$ \phi $$ is computed using

(11.94)

subject to

(11.95)

Applying the conditions given by Eq. (11.95), the profile for $$ \phi $$ is found to be

(11.96)

For the case of a uniform grid, the value of $$ \phi $$ at the cell face f reduces to

(11.97)

Thus, the convective fluxes at the element faces can be computed as

(11.98)

Substituting back in the one dimensional convection-diffusion equation [Eq. (11.16)], the discretized form becomes

(11.99)

which can be modified into the form

(11.100)

with the coefficients given by

(11.101)

11.5.8 Truncation Error

Again following the procedure described above, the truncation error is found to be

(11.102)

which is clearly third order accurate.

11.5.9 Stability Analysis

To check the stability of the QUICK scheme, the discretized convective fluxes are substituted in Eq. (11.75) resulting in the following $$ RHS_{convection} $$ term:

(11.103)

The rate of change of this term with respect to $$ \phi_{C} $$ is found to be given by

(11.104)

which for a uniform velocity is always negative indicating a stable scheme. However this does not guarantee solution boundedness especially in the general case of nonuniform velocity.

11.5.10 The FROMM Scheme

The FROMM scheme [12] fits a linear profile between the far Upwind (U) and Downwind (D) nodes straddling the interface. As depicted in Fig. 11.13, instead of a symmetric profile, an upwind biased stencil is used to calculate the value of the dependent variable $$ \phi $$ at face f. Based on the adopted profile, $$ \phi_{U} $$, $$ \phi_{C} $$, and $$ \phi_{D} $$ are assumed to be collinear.

Fig. 11.13

The FROMM scheme profile

11.5.11 The Interpolation Profile

Starting with the linear profile

(11.105)

and fitting it to the nodal values at $$ x_{D} $$ and $$ x_{U} $$ where the $$ \phi $$ values are $$ \phi_{D} $$ and $$ \phi_{U} $$, respectively, the profile becomes

(11.106)

Using the above equation, the $$ \phi $$ value at upwind node C is obtained as

(11.107)

For the case of a uniform grid the above equation becomes

(11.108)

The required value at the face f, shown in Fig. 11.13, is given by

(11.109)

which, for a uniform grid reduces to

(11.110)

The final expression for $$ \phi_{f} $$ given in Eq. (11.109) was obtained by invoking Eq. (11.107).

11.5.12 The Discretized Equation

Using this profile to approximate the interface values in the discretized one dimensional convection diffusion equation (Eq. 11.16), the fluxes at the faces are obtained as

(11.111)

Substitution of these fluxes in Eq. (11.16), the discretized form is transformed to

(11.112)

which can be modified into the form

(11.113)

where

(11.114)

11.5.13 Truncation Error

Following a procedure similar to the one used with the central difference scheme, the truncation error can be derived to be of $$ O\left( {\Delta x^{2} } \right) $$, i.e.,

(11.115)

indicating second order accuracy.

11.5.14 Stability Analysis

To check the stability of the FROMM scheme, the discretized convective fluxes are substituted in Eq. (11.75) resulting in the following RHS convection term:

(11.116)

The rate of change of this term with respect to $$ \phi_{C} $$ is found as

(11.117)

which, for a constant velocity field, is always negative indicating a stable scheme, but not for the general case when the velocity is varying.

11.5.15 Comparison of the Various Schemes

By comparing the stability of the various schemes presented so far, it is clear that the most negative (with a coefficient of −3/2) is the one associated with the SOU scheme. This is followed by the upwind (with a coefficient of −1), then FROMM (with a coefficient of −3/4), after that QUICK(with a coefficient of −3/8), and finally the central difference scheme (with a coefficient of zero, i.e., a neutral sensitivity to changes in $$ \phi_{C} $$ ). The self corrective action discussed above is the sum of both convection and diffusion contributions. The false diffusion produced by the upwind scheme adds to its stability and even though its coefficient is −1, is the most stable scheme. This is demonstrated by the profiles presented in Fig. 11.14, which represent the solutions using the various numerical schemes of the convection-diffusion equation over a domain of length L = 1 and subject to the Dirichlet conditions of $$ \phi = 1 $$ at x = 0 and $$ \phi = 0 $$ at x = 1. While all solutions are stable at low Péclet number (i.e., Pe = 1, Fig. 11.14a), the CD, FROMM, and QUICK scheme solutions shown in Fig. 11.14b are seen to be wiggly at Pe = 10. At low Pe, the accuracy of the CD and QUICK schemes is comparable and their solutions are very close to the exact solution. The least accurate is the solution produced by the first order upwind scheme. The solution of the FROMM scheme is more accurate than the SOU scheme, which, in turn, is more accurate than the upwind scheme solution, while both the FROMM and SOU scheme solutions are less accurate than the QUICK scheme solution.

Fig. 11.14

Stability of solutions generated using several convective schemes at two values of cell Péclet number of a 1 and b 10

At high Pe, the behavior of the schemes changes. The only stable solutions are the ones obtained by the upwind and SOU schemes with their profiles being almost identical indicating that the SOU scheme is still highly diffusive. The CD scheme is wiggly over most of the domain. The FROMM and QUICK schemes, on the other hand, show wiggles but of smaller amplitudes. The reason for these wiggles is the imposed boundary condition at exit from the domain. As the phenomenon is convection dominated, it is affected by upstream values. At exit from the domain, the solution faces an imposed value that it has to satisfy, resulting in a large unexpected gradient causing the over and under shoots to occur. The diffusive upwind and SOU schemes being based on upstream values only, are smooth and do not show any sign of under/overshoots for all Pe values as the solution is independent of the imposed value at exit. However the SOU scheme is expected to give rise to oscillations (over/under shoots) in the presence of a high gradient in the domain like in the presence of a shock wave.

11.5.16 Functional Relationships for Uniform and Non-uniform Grids

The various interpolation profiles presented so far have been derived on a one dimensional Cartesian grid. Along a curvilinear coordinate axis, the same functional relationships can be used by replacing the Cartesian x-axis by a curvilinear $$ \zeta $$-axis, as shown in Fig. 11.15. For uniform grid, the functional relationships remain exactly the same, independent of whether a Cartesian or a curvilinear grid system is used. For non-uniform grid, the independent variable x appearing in the functional relationships should be replaced by the more general independent variable $$ \zeta $$, which represents distance along the coordinate axis. If O is the origin (Fig. 11.15), then $$ \zeta_{U} $$ for example is calculated as

(11.118)

Therefore distances are calculated by subdividing the curvilinear line into a number of straight lines and in general the following applies:

(11.119)

Adopting a general coordinate system, the functional relationships for the various schemes presented so far on uniform and non-uniform grids can be derived to be as shown in Table 11.1.

Fig. 11.15

Notation on a curvilinear coordinate axis $$ {\varvec{\zeta}} $$

Table 11.1

Functional relationships for several convection schemes on uniform and non-uniform grids

Scheme

Uniform grid

Non-uniform grid

Upwind

Downwind

CD

SOU

QUICK

FROMM

11.6 Steady Two Dimensional Advection

The steady two dimensional advection equation is given by

(11.120)

Integrating over the two-dimensional element of volume V C shown in Fig. 11.16, using the divergence theorem, and replacing the surface integral by a summation over the element faces, Eq. (11.120) becomes

(11.121)

Using a single Gaussian point for the face integral, the left hand side of Eq. (11.121) is transformed to

(11.122)

Substitution of Eq. (11.122) in Eq. (11.121) yields

(11.123)

The full discretized form of Eq. (11.120) over a Cartesian grid is obtained as

(11.124)

Adopting an upwind scheme in each coordinate direction by treating the flow as locally one dimensional, Eq. (11.124) becomes

(11.125)

with the coefficients given by

(11.126)

If the QUICK scheme is used, the discretized equation is changed into

(11.127)

with its coefficients computed as

(11.128)

Both discretized equations are used to solve the pure advection of a step profile in an oblique velocity field problem. The physical domain is schematically depicted in Fig. 11.17a. It represents a square domain with a property $$ \phi $$ being convected in a field with a velocity v(1,1). The value of $$ \phi $$ is 1 on the left side of the domain and 0 on the bottom. In the absence of any diffusion, the exact solution is $$ \phi = 1 $$ above the diagonal shown in Fig. 11.17a and $$ \phi = 0 $$ below it. Figure 11.17b compares the exact profile at x = 0.5 with similar ones obtained numerically using the upwind and QUICK schemes.

Fig. 11.16

Notation for a two dimensional Cartesian grid system

Fig. 11.17

a Physical domain and b $$ {\phi } $$ profiles along the vertical centerline of the domain for pure advection of a step profile in an oblique velocity field

In comparison with the exact solution, the profile generated by the upwind scheme is smeared and highly inaccurate but very smooth. This inaccuracy is due to a new type of error known as cross-stream diffusion, which is caused by the one-dimensional interpolation profile used, i.e., it is due to treating the flow as locally one dimensional. The origin of cross-flow diffusion was identified by Patankar [4] and Stubley [13] as being a multi - dimensional phenomenon. It occurs only when the velocity field is not aligned with the grid. An approximate expression for the cross flow diffusion has been given by de Vahl Davis and Mallinson [14] for two dimensional flows as

(11.129)

where $$ \left| {\mathbf{v}} \right| $$ is the velocity magnitude and $$ \theta $$ the angle made by the velocity vector with the x coordinate axis. This error can be reduced by using higher order interpolation schemes as demonstrated by the profile generated with the QUICK scheme. The QUICK scheme profile is shown to be much sharper and more accurate than the upwind profile however it is infected with over/undershoots near the sharp gradient. As mentioned earlier this error is called the dispersion error, which causes the generation of maxima/minima in the solution domain and is a characteristic of all High Order (HO) schemes.

11.6.1 Error Sources

Based on the discussions in the previous sections the sources of numerical error in the discretization of the convective flux can be divided into numerical diffusion and numerical dispersion.

Numerical diffusion, which causes smearing of sharp gradients (Fig. 11.18a) can also be divided into stream wise and cross stream numerical diffusion. Stream wise numerical diffusion can be reduced by increasing the order of the interpolation profile, as shown in Fig. 11.18b, resulting in sharper profiles but inducing under/overshoots in the presence of large gradients. Cross-stream numerical diffusion, shown in Fig. 11.17b, is caused by the one dimensional nature of the assumed profile and can be reduced either by interpolating in the direction of the flow (i.e., multi-dimensional profiles) [15, 16] or by using one-dimensional higher order interpolation profiles (Fig. 11.18b).

Fig. 11.18

a Smearing of sharp profiles by numerical diffusion and b wiggles in the computed profile due to numerical dispersion

Numerical dispersion error manifests itself through oscillation in the generated profile in the presence of large gradients rendering the solution unbounded. As shown in Figs. 11.18b and 11.19 and the results reported in Fig. 11.14b, it exists with all assumed interpolation profiles except the upwind scheme. It is the result of the unphysical behavior of the assumed interpolation profile.

Fig. 11.19

Numerical dispersion error causing oscillations in the presence of a large gradient

An evaluation of this error can be obtained by using a simplified version of Eq. (11.73) in which diffusion and sources are neglecting. If further, velocity and density fields are considered constants, Eq. (11.73) simplifies to

(11.130)

Assuming an exact solution of the form

(11.131)

where j is the imaginary number defined by j 2  = −1. Then the exact value of the gradient becomes

(11.132)

With an interpolation profile, the numerical approximation of the gradient is written in terms of $$ \phi $$ values at locations $$ - M\Delta x,\,\left( { - M + 1} \right)\Delta x,\, \ldots ,\,\Delta x,\,2\Delta x,\, \ldots ,N\Delta x $$ as

(11.133)

which, upon substitution of the assumed solution, becomes

(11.134)

By comparing the exact and numerical solutions, it is found that

(11.135)

In general k is an imaginary number that can be written as

(11.136)

where Re and Im refer to the real and imaginary part, respectively. Inserting k in the exact solution, the approximate solution is obtained as

(11.137)

Therefore, the numerical solution may include both diffusion (or dissipative) and dispersion errors. If k is real, only dispersion error occurs. However if k is complex, then both types of errors will arise. Based on this analysis, the value of k for the upwind and CD schemes can be checked. For the upwind scheme, the gradient is computed as

(11.138)

It is clear that the upwind scheme gives rise to both types of errors. For the central difference scheme, the gradient is given by

(11.139)

Since k is imaginary, then only numerical dispersion error arises. This dispersion error causes oscillations and under/overshoots in the solution.

Having developed a better understanding of numerical dispersion, it is desirable to develop convective non-oscillatory schemes of high order of accuracy. This has kept researchers busy for an extended period of time until the bounding of the convective flux became understood. The development of such schemes will be detailed in the next chapter.

11.7 High Order Schemes on Unstructured Grids

As for structured grids, the functional relationships of HO schemes are defined as functions of the values at the U, C, and D nodes. While the C and D nodes are readily available for any interior face (Fig. 11.20a), defining the U node is not straightforward (Fig. 11.20b, c) in an unstructured grid. A simple way around this difficulty is to simply redefine HO schemes in terms of the gradients at the C and D nodes, or a combination of thereof. Another approach is to reconstruct a pseudo U node, which will be detailed in the next chapter and used in developing HR schemes.

Fig. 11.20

a An element in an unstructured grid; the upwind node for HO and HR convection schemes in unstructured grids when the velocity at the element face is b negative or c positive

11.7.1 Reformulating HO Schemes in Terms of Gradients

This approach relies on profiles developed over structured grids and is best explained by rewriting the QUICK [2] scheme using the new terminology and then generalizing results for any second order profile developed using three points. The functional relationship of the QUICK [2] scheme can be written as

(11.140)

By approximating the gradients at the locations C and f in the $$ {\mathbf{d}}_{CF} $$ or $$ \zeta $$ direction as shown in Fig. 11.19, then the gradients at the centroids C and f are computed as

(11.141)

Using Eq. (11.141), Eq. (11.140) can be recast into

(11.142)

or

(11.143)

Denoting the vector between C and f by $$ {\mathbf{d}}_{Cf} $$, in vector form the above equation becomes

(11.144)

which is quite suitable for use in the context of unstructured grids since it only requires information related to gradient at the C and f locations. As long as the computation of these gradients is second order accurate, the way they are calculated becomes immaterial. This gives higher flexibility, as compared to the original formulation, over unstructured grids. Furthermore, Eq. (11.144) suggests that a profile based on three points can be written as

(11.145)

where the constants a, b, and c are determined by equating $$ \phi_{f} $$ to the profile obtained over structured grids. The general discretized form of Eq. (11.145) can be found once and then used in all subsequent derivations. This is derived by first substituting the approximate values of the gradients using Eq. (11.141) to yield

(11.146)

and then after some algebraic manipulations the final form is obtained as

(11.147)

Using the above equation, the calculation of the a, b, and c coefficients is easily accomplished. For example the SOU profile in terms of the gradients can be found as follows:

(11.148)

Thus the equivalent form of the SOU scheme is given by

(11.149)

Following the same procedure, the gradient forms of the schemes presented earlier are found to be

(11.150)

(11.151)

(11.152)

(11.153)

(11.154)

(11.155)

A full chapter was devoted to the calculation of the gradient at the element centroid and faces and the reader is referred to Chap. 9 for the calculation of $$ {{\nabla}} \phi_{C} $$ and $$ {{\nabla}} \phi_{f} $$.

11.8 The Deferred Correction Approach

The Deferred Correction (DC) procedure of Khosla and Rubin [17] is a compacting technique that enables the use of HO schemes in codes initially written for low order schemes without violating any of the stability rules. The approach is applicable on any type of structured or unstructured grid systems. The method is based on writing the convection flux at a cell face f calculated using a HO scheme as

(11.156)

where the superscripts U and HO refer to the Upwind and High Order scheme, respectively. By expressing the convection flux in this way, the first term on the right hand side (RHS) is implicitly evaluated by expressing it in terms of nodal values, while the second term on the RHS is evaluated explicitly using the latest available $$ \phi $$ values, i.e., values from the previous iteration in an iterative solution procedure. In terms of nodal values, Eq. (11.156) is expressed as

(11.157)

where

(11.158)

Substituting the convection flux given by Eqs. (11.157) and (11.158) in Eq. (11.156) and rearranging, the final form of the algebraic equation is obtained as

(11.159)

where

(11.160)

and

(11.161)

the $$ b_{C}^{DC} $$ represents the extra source term arising due to the DC procedure. Moreover, the DC technique results in an equation for which the coefficient matrix is always diagonally dominant since it is formed using the upwind scheme.

Example 2

Derive the coefficients for a deferred correction implementation of the QUICK scheme

Solution

The conservation equation is discretized into the following algebraic equation in every cell:

For the quick scheme the value at a cell face is computed as

The coefficients of the algebraic system of equations in a deferred correction approach are based on the UPWIND convection scheme. As such these coefficients are given by

The difference between the UPWIND and QUICK schemes is explicitly accounted for in the source term which is modified to

This compacting procedure is simple to implement, however as the difference between the cell face values calculated with the upwind scheme and that calculated with the HO scheme becomes larger, the convergence rate diminishes.

11.9 Computational Pointers

11.9.1 uFVM

The assembly of the convection term in uFVM is performed in cfdAssembleConvectionTerm, where the assembly for the upwind scheme is performed first for interior faces (cfdAssembleConvectionTermInterior), then for boundary faces by looping over the various boundary patches (cfdAssembleConvectionTermInletBC, cfdAssembleConvectionTermOutletBC, etc.).

The core of the interior faces assembly routine is shown in Listing 11.1. The owner and neighbor indices for the interior faces are first retrieved and an upwind index is defined (pos). Then the coefficients for the upwind scheme are computed.

Listing 11.1

Convection scheme class declaration

The implementation of High Order schemes is performed after the upwind assembly using the deferred correction method. The assembly of the QUICK scheme (cfdAssembleConvectionTermDCQUICK) is shown in Listing 11.2.

Listing 11.2

Assembly of the QUICK scheme

The deferred correction value is computed for all interior faces as

(11.162)

11.9.2 OpenFOAM®

In OpenFOAM® [18] the convection term can be evaluated either explicitly using fvc::div(mDot, phi) or implicitly via the fvm::div(mDot,phi) function. The fvc::div(mDot,phi) returns a field in which the divergence of phi is evaluated in each cell. The field is added to the right hand side of the system of equations. The fvm::div(mDot,phi) returns the fvMatrix, a matrix of coefficients that are evaluated based on the linearization of the face fluxes. The matrix of coefficients is then added to the left hand side of the system of equations.

The scripts of fvm::div and fvc::div functions can be found in the file FOAM_SRC/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionSheme.C. As already stated, the convection class is based on the type of interpolation scheme at the face and accordingly the declaration of the class is performed as displayed in Listing 11.3.

Listing 11.3

Convection scheme class declaration

In the above declaration the private member tinterpScheme_ describes the face interpolation type on which the divergence operator is based. Additionally to the above mentioned function, the gaussConvectionScheme class defines two auxiliary functions named interpolate and flux, as shown in Listing 11.4, which wrap the surfaceInterpolation class used to perform interpolation from volume fields to surface fields.

Listing 11.4

The gaussConvectionScheme class that defines the interpolate and flux functions

For the explicit discretization of convection, the operator defines a field where the divergence of the cell face fluxes are stored. The code used by the fvc::div operator for the explicit evaluation of the divergence of a field over a specific volume is as follows (Listing 11.5):

Listing 11.5

Script used for the explicit evaluation of the divergence operator

The calculation of the divergence of a field involves the following three steps:

1.

Evaluating values at the faces of the element.

2.

Multiplying the value at the face with the mass flux at the face (i.e., faceFlux).

3.

Summing the contributions of all cell faces and dividing the sum by the cell volume.

First the face value of the generic variable vf is evaluated. Then the estimate obtained is multiplied by the corresponding face mass flux value using auxiliary functions. Finally the sum over the faces of the cell is performed using the surfaceIntegrate function. The implementation of this function can be found under FOAM_SRC/finiteVolume/finiteVolume/fvc/fvcSurfaceIntegrate.C and its script is given in Listing 11.6.

Listing 11.6

Script of the surfaceIntegrate function

The implicit discretization of the convection term is performed using the fvm::div operator. It does so by implicitly expressing the dependent variable value at the face as function of the owner and neighbor values according to

(11.163)

where subscripts O and N refer to owner and neighbor, respectively, and $$ \varpi $$ represents the weight assigned to the contribution of the owner to the value at the face. The way the weight is calculated will be described in the next chapter. The coefficients of $$ \phi_{O} $$ and $$ \phi_{N} $$ are then used to assemble the matrix of coefficients. The script used to perform implicit discretization of the divergence operator reads (Listing 11.7)

Listing 11.7

Implicit calculation of the divergence of a field

where in a first place an fvMatrix is defined and then, as shown in Listing 11.8, it is properly filled with the corresponding coefficients as

Listing 11.8

Properly assembling the weights contributions to coefficients

where the upper and lower vectors are now defined using the interpolation weights denoted tweights, as described above. Further, Eq. (11.163) indicates that the implementation of the implicit operator in OpenFOAM® is based on the so called “downwind” discretization (as explained later) in which all schemes are discretized in a fully implicit manner independently of the order of accuracy and without using a deferred correction approach. This technique is also similar to the downwind weighing factor method that will be described in the next chapter.

As described above for both explicit and implicit discretization methods, the divergence operator for the calculation of the convection term is based on the face interpolation and the calculation of the weights. OpenFOAM®performs these tasks in a base class denoted by surfaceInterpolationScheme. From this base class a large number of interpolation schemes are derived and implemented, as shown in the UML graph depicted in Fig. 11.21. For better understanding, additional details about this class are given next.

Fig. 11.21

UML Graph for the surfaceInterpolationScheme class, where a box with a black border denotes a documented struct or class for which not all inheritance/containment relations are shown

As mentioned above, the fvc::div and fvm::div operators use the surfaceInterpolationScheme class to perform the needed tasks for each discretization method. In this class, the functions used to calculate the values at the faces (vf) and the weights are displayed in Listings 11.9 and 11.10, respectively, and where tinterpScheme_ (Listing 11.10) is a surfaceInterpolationScheme object.

Listing 11.9

The interpolation function where the value at the face (vf) is computed

Listing 11.10

The function used to calculate the weights

and

The definition of the class can be found in FOAM_SRC/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.H where the two main functions (Listings 11.11 and 11.12), necessary for the calculation of the divergence operator are defined.

Listing 11.11

Definition of the main function for face interpolation

Listing 11.12

Definition of the main function for weight factors calculation

The interpolate function in Listing 11.9 (here OpenFOAM® adopts the same function name but for a different implementation) is used with the explicit operator fvc::div and is defined as a normal virtual function meaning that a derived class may or may not adopt it. For most of the derived classes this function is not selected and the definition in the surfaceInterpolationScheme class is based on a modified form of Eq. (11.163) written as

(11.164)

To implement Eq. (11.164), OpenFOAM® uses auxiliary functions with names similar to the ones used earlier in the surfaceInterpolationScheme class. First an interpolate class with a single argument is instantiated from the divergence operator. Then inside the interpolate function a new interpolate function with two arguments is introduced along with a new weights function, using the script shown in Listing 11.13.

Listing 11.13

The new interpolate function with two arguments

The new interpolate function (the one with the two arguments) compute the face value according to Eq. (11.164). The script used to perform this task is given by (Listing 11.14)

Listing 11.14

Script used to compute face values according to Eq. (11.164)

where lambda represents the weight $$ \varpi $$ in Eq. (11.164).

As briefly introduced above, the weights function is now a pure virtual function and it defines the weights of the interpolation. Contrary to the interpolate function, the weights function being pure virtual has to be redefined for every derived class (C⁺⁺ requirement). Looking again at Fig. 11.20, all derived classes have to define the weights function. The redefinition must be performed by constructing the proper weights corresponding to the scheme adopted.

For the case of the central difference scheme the weights function is defined in a class named linear<Type> with its script given by (Listing 11.15),

Listing 11.15

Script for calculating the weights of the central difference scheme

where surfaceInterpolation::weights() returns the distance weights based on the mesh, thus defining the central difference discretization.

Another example is the downwind scheme defined by Eq. 11.44, and for which the weights function is given by (Listing 11.16)

Listing 11.16

Script for calculating the weights of the downwind scheme

where the neg function returns 0 for positive fluxes and 1 for negative ones, which is the opposite of the pos function used with the upwind scheme.

11.10 Closure

The chapter dealt with the discretization of the convection term. The difficulties associated with the use of a linear symmetrical profile were discussed and remedies suggested. The upwind scheme, although stable and generates physically plausible results, is highly diffusive smearing sharp gradients and producing results that are first order accurate. Upwind-biased HO convection schemes were shown to improve accuracy but to produce a new type of error known as the dispersion error, which manifest itself in the solution through wiggles, oscillations, and over/under shoots across sharp gradients. No attempt was made to address this error in this chapter. Among other issues, this will form the subject of the next chapter that further expands on the discretization of the convection term.

11.11 Exercises

Exercise 1

(a)

Find third order accurate expressions, i.e., $$ O\left( {\Delta x^{3} } \right) $$, of $$ \phi_{U} $$, $$ \phi_{C} $$, and $$ \phi_{D} $$ by using a Taylor series expansion about the face f for the one dimensional uniform grid shown in Fig. 11.22.

Fig. 11.22

A uniform one dimensional grid system

(b)

Derive a high-order scheme using a linear combination $$ \left( {a\phi_{U} + b\phi_{C} + c\phi_{D} } \right) $$ of these expressions in such a way as to eliminate the first and second order derivatives from the final expression for $$ \phi_{f} $$ with the additional condition that a + b + c = 1.

(c)

Prove that the scheme you just derived is third order accurate in its representation of the convection operator.

Exercise 2

The QUICK scheme fits a quadratic function to three nodal values to estimate the value of a scalar at a cell face, according to

(a)

For a uniform cartesian two dimensional grid write down the expressions for $$ \phi_{e} $$, $$ \phi_{w} $$, $$ \phi_{n} $$ and $$ \phi_{s} $$ in terms of the values at neighboring nodes, assuming that the velocity components u and v are known, constant, and positive.

(b)

Neglecting diffusion and assuming a uniform source $$ Q^{\phi } $$ per unit volume, derive an algebraic discretization of the $$ \phi $$ scalar conservation equation given by

in the form

assuming that a cell is of unit depth, with the area of its e, w, n, and s faces denoted by S e , S w , S n , and S s , respectively, and its volume by V C .

(c)

Splitting the QUICK expression for $$ \phi_{f} $$ into the form “Upwind differencing” + “deferred correction” so that the coefficients become similar to those of the upwind scheme, then moving the deferred correction to the source term, write an expression for this source term.

Exercise 3

In a steady two dimensional situation, the variable $$ \phi $$ is governed by

where $$ \rho = 1 $$, $$ Q^{\phi } = 15 - 3\phi $$.

The flow field is such that v = li + 4j everywhere and $$ \Delta x =\Delta y = 1 $$. The domain is discretized using the orthogonal grid shown in Fig. 11.23 with the values of $$ \phi $$ given at the inlet boundaries as shown in the figure. Using the finite volume approach and the Second Order Upwind convection scheme to

(a)

derive the algebraic equations for the four control volumes, and

(b)

compute the values of $$ \phi_{1} $$, $$ \phi_{2} $$, $$ \phi_{3} $$ and $$ \phi_{4} $$ using 3 iterations of a simple Gauss-Siedel type solver.

Fig. 11.23

A two dimensional configuration discretized using a non-uniform Cartesian grid for the advection of a scalar $$ {\phi} $$ in the presence of a source term

Exercise 4

Consider the steady transport of a scalar $$ \phi $$ in the domain shown in Fig. 11.24. The governing conservation equation is given by

where $$ \rho = 1 $$, v = 2yx ² i − 2x y ² j, and $$ \Delta x =\Delta y = 1/3 $$.

(a)

Using the UPWIND scheme, discretize the equation over the computational domain and find the value of $$ \phi $$ at each element centroid.

(b)

Using the QUICK scheme, applied via a deferred correction approach, discretize the equation over the computational domain and find the value of $$ \phi $$ at each element centroid.

Fig. 11.24

Convection of a two dimensional scalar field

Exercise 5 (OpenFOAM®)

(a)

Using Doxygen [19], list all derived classes of the surfaceInterpolationScheme <Type> class (these classes implement the virtual interpolate function).

(b)

Describe the weights function of the class midPoint<Type>, downwind<Type> and linear<Type>.

(c)

Write a class that inherits the surfaceInterpolationScheme <Type> class and implements the interpolate function using a geometric average.

Exercise 6 (OpenFOAM®, uFVM)

The advection of a step profile in an oblique velocity field, v = 2i + j, shown in Fig. 11.25 is governed by

For different grid sizes, setup the problem and solve it in OpenFOAM® and uFVM using the following advection schemes assuming unit dimensions in x and y directions, and compare results with the exact solution $$ \left( {\rho = 1} \right) $$:

(a)

UPWIND

(b)

QUICK

(c)

SOU

Fig. 11.25

Advection of a step profile in an oblique velocity field

Exercise 7 (OpenFOAM®, uFVM)

The Smith-Hutton test governed by

and illustrated in Fig. 11.26, involves the pure advection of a step profile in a rotational velocity field described as

For different grid sizes, solve the test in openFOAM® and uFVM using the following advection schemes, and compare results with the exact solution $$ \left( {\rho = 1} \right) $$:

(a)

UPWIND

(b)

QUICK

(c)

SOU

Fig. 11.26

Advection of a step profile in a two dimensional rotational velocity field

References

1.

Spalding DB (1972) A novel finite difference formulation for differential expressions involving both first and second derivatives. Int J Numer Meth Eng 4:551–559CrossRef

2.

Leonard BP (1979) A stable and accurate convective modelling procedure based on quadratic upstream interpolation. Comput Methods Appl Mech Eng 19:59–98MATHCrossRef

3.

Raithby GD (1976) A critical evaluation of upstream differencing applied to problems involving fluid flow. Comput Methods Appl Mech Eng 9:75–103MATHMathSciNetCrossRef

4.

Patankar SV (1980) Numerical heat transfer and fluid flow. Hemisphere Publishing Corporation, McGraw-HillMATH

5.

Patankar SV, Baliga BR (1978) A new finite-difference scheme for parabolic differential equations. Numer Heat Transf 1:27–37CrossRef

6.

Courant R, Isaacson E, Rees M (1952) On the solution of nonlinear hyperbolic differential equations by finite differences. Commun Pure Appl Math 5:243–255MATHMathSciNetCrossRef

7.

Moukalled F, Darwish M (2012) Transient schemes for capturing interfaces of free-surface flows. Numer Heat Transf Part B Fundam 61(3):171–203CrossRef

8.

Darwish M, Moukalled F (2006) Convective schemes for capturing interfaces of free-surface flows on unstructured grids. Numer Heat Transf Part B Fundam 49(1):19–42CrossRef

9.

Leonard BP (1979) A survey of finite difference of opinion on numerical muddling of the incomprehensible defective confusion equation. In: Hughes TJR (ed) Finite element methods for convection dominated flows, AMD-34, ASME

10.

Shyy W (1985) A study of finite difference approximations to steady state convection dominate flow problems. J Comput Phys 57:415–438MATHMathSciNetCrossRef

11.

Leonard BP, Leschziner MA, McGuirk J (1978) Third order finite-difference method for steady two-dimensional convection. In: Taylor C, Morgan K, Brebbia CA (eds) Numerical methods in laminar and turbulent flows. Pentech Press, London, pp 807–819

12.

Fromm JE (1968) A method for reducing dispersion in convective difference schemes. J Comput Phys 3:176–189MATHCrossRef

13.

Stubley GD, Raithby GD, Strong AB (1980) Proposal for a new discrete method based on an assessment of discretization errors. Numerical Heat Transfer 3:411–428CrossRef

14.

de Vahl Davis G, Mallinson GD (1972) False diffusion in numerical fluid mechanics. University of New South Wales, School of Mechanical and Industrial Engineering (Report 1972/FMT/1)

15.

Raithby GD (1976) Skew upstream differencing schemes for problems involving fluid flow. Comput Methods Appl Mech Eng 9:153–164MATHMathSciNetCrossRef

16.

Darwish M, Moukalled F (1996) A new route for building bounded skew-upwind schemes. Comput Methods Appl Mech Eng 129:221–233MATHMathSciNetCrossRef

17.

Khosla PK, Rubin SG (1974) A diagonally dominant second-order accurate implicit scheme. Comput Fluids 2:207–209MATHCrossRef

18.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

19.

OpenFOAM Doxygen (2015) Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_12

12. High Resolution Schemes

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter continues the development of convection schemes and discusses approaches by which boundedness is enforced on High Order (HO) convection schemes to produce High Resolution (HR) schemes. The recipe for a HR scheme is shown to involve a combination of a HO profile and a Convection Boundedness Criterion (CBC) ensuring that no oscillatory behavior is experienced in the solution. The Normalized Variable Formulation (NVF) and the Total Variation Diminishing (TVD) frameworks for developing HR schemes are introduced. Even though the two approaches look very different they are shown to be almost identical. The Normalized Variable Diagram (NVD) and Sweby’s (or $$ r - \psi $$) diagram for visualizing HR schemes in the NVF and TVD formulation, respectively, are presented. The functional relationships for several HR schemes are specified in the context of both the NVF and TVD formulations. In addition to the Deferred Correction (DC) procedure discussed in the previous chapter, two additional techniques for the implementation of HO and HR schemes in structured and unstructured grids are introduced, namely the Downwind Weighing Factor (DWF) method and the Normalized Weighing Factor (NWF) method.

12.1 The Normalized Variable Formulation (NVF)

The Normalized Variable Formulation (NVF) is a framework for the description and analysis of High Resolution (HR) schemes. It was introduced by Leonard [1–3] and gained popularity with the Gaskell and Lau simplified Convection Boundedness Criterion (CBC) [4]. The Normalized Variable Diagram (NVD) is a useful tool for the development and analysis of HO and HR schemes.

The NVF is a face formulation procedure based on locally normalizing the dependent variable for which the value $$ \phi_{f} $$ at face f is to be constructed. The approach relies on the upwind $$ \left( {\phi_{C} } \right), $$ downwind $$ \left( {\phi_{D} } \right), $$ and far upwind $$ \left( {\phi_{U} } \right) $$ node values, illustrated in Fig. 12.1, to express the normalized variable as

(12.1)

Fig. 12.1

A schematic showing a the U, C, and D node locations used in describing convection schemes on structured grids b the C, D and extrapolated U nodes for an unstructured grid

With this normalization the relation

(12.2)

is transformed to

(12.3)

since the normalized values of $$ \phi_{D} $$ and $$ \phi_{U} $$ become equal to

(12.4)

while the normalized value of $$ \phi_{C} \left( {\tilde{\phi }_{C} } \right) $$ becomes an indicator of smoothness for the $$ \phi $$ field. Values of $$ \tilde{\phi }_{C} $$ between 0 and 1 $$ \left( {0 < \tilde{\phi }_{C}} < 1 \right), $$ represent a monotonic profile while values of $$ \tilde{\phi }_{C} $$ that are less than 0 $$ \left( {\tilde{\phi }_{C}} < 0 \right) $$ or greater than 1 $$ \left( {\tilde{\phi }_{C} } > 1 \right) $$ indicate an extremum at C. In addition, values of $$ \tilde{\phi }_{C} \approx 0 $$ or $$ \tilde{\phi }_{C} \approx 1 $$ indicate a gradient jump. These configurations are illustrated in Fig. 12.2.

Fig. 12.2

Schematics of the situations when a $$ \tilde{\phi }_{C} < 0, $$ b $$ \tilde{\phi }_{C} > 1, $$ c $$ \tilde{\phi }_{C} = 1, $$ d $$ \tilde{\phi }_{C} = 0 , $$ and e $$ 0 < \tilde{\phi }_{C} < 1 $$

Normalization is also useful for transforming the functional relationships of HO schemes into linear relations between $$ \tilde{\phi }_{f} $$ and $$ \tilde{\phi }_{C} . $$ For example, the normalized functional relationships of the HO schemes presented in the previous chapter are as follows:

(12.5)

(12.6)

(12.7)

(12.8)

(12.9)

(12.10)

Thus, for all HO schemes that are based on three nodal values, $$ \tilde{\phi }_{f} $$ can always be expressed as a linear function of $$ \tilde{\phi }_{C} , $$ i.e., $$ \tilde{\phi }_{f} = \ell \tilde{\phi }_{C} + k, $$ where the values of $$ \ell $$ and k depend on the scheme. Therefore, if $$ \tilde{\phi }_{f} $$ is plotted as a function of $$ \tilde{\phi }_{C} $$ in the $$ \left( {\tilde{\phi }_{C} ,\tilde{\phi }_{f} } \right) $$ plane, then the functional relationships of these schemes will appear as straight lines on the plot. The resultant plot is denoted by the Normalized Variable Diagram (NVD). An NVD on which the functional relationships of the above schemes are plotted is displayed in Fig. 12.3.

Fig. 12.3

Some HO schemes written in normalized form and plotted on a Normalized Variable Diagram (NVD)

Example 1

Derive the NVF form of the QUICK scheme.

Solution

Starting with

Applying normalization to both sides yields

noting that

the following is obtained:

thus

The NVD reveals that except for the first order upwind and downwind schemes, all second order and third order schemes pass through the point $$ Q\left( {0{.}5{,}\, 0{.}75} \right) $$ (for uniform grids). In fact, it can be shown that for a scheme to be second order accurate it has to pass through Q. If, in addition, its slope at Q is 0.75 then it will be third order accurate (e.g., QUICK). The upwind scheme was shown to be very diffusive, while the downwind scheme very compressive (anti-diffusive). Therefore, from the NVD it can graphically be deduced that any scheme whose functional relationship is close to the upwind scheme is diffusive while anyone close to the downwind scheme is compressive.

Example 2

Show that for schemes developed over uniform cartesian grids to be second order accurate their functional relationships should pass through the point $$ Q\left( {1/2,\,3/4} \right) $$ in the NVD.

Solution

Second order schemes involve three points. Expanding $$ \phi_{C} , \phi_{U} , $$ and $$ \phi_{D} $$ in terms of $$ \phi_{f} , $$ the following is obtained:

The value of $$ \phi_{f} $$ is generally obtained as a combination of the values at the three locations as

The value of $$ \phi_{f} $$ will be second order accurate if

A first order approximation of $$ \phi_{f} $$ is obtained as

For the above approximation to be second order accurate the following should be true:

The above equality will be satisfied for any value of a and c, and consequently any second order scheme, when $$ \tilde{\phi }_{f} = 3/4 $$ and $$ \tilde{\phi }_{C} = 1/2, $$ in which case

Therefore all second order schemes pass through the point $$ Q\left( {1/2,\,3/4} \right). $$

The HO schemes presented in the previous chapter were shown to drastically decrease the truncation error suffered by the first order upwind scheme, while remaining stable. Still, one of the main shortcomings of these schemes is their unboundedness, i.e., their tendency to produce under/overshoots and even oscillations near sudden jumps or steep gradients in the convected variable (see Figs. 11.​14b and 11.​17). While in some applications small overshoots and/or oscillations may be tolerable, in others, they can lead to catastrophic results, such as in turbulent flow calculations where the convected variable can be the viscosity coefficient.

This oscillatory behavior near steep gradients characterizes all HO linear convective schemes. In fact these schemes are not monotonous in the sense that they produce local maxima and/or minima, i.e., they are not extrema preserving. For a scheme to be extrema preserving, maxima in the solution must be non-increasing and minima non-decreasing (the scheme should not produce over/under shoots). In fact it was demonstrated by Godunov and Ryabenki [5] that any linear numerical scheme that is monotone can be at most first-order accurate. This implies that all higher order linear schemes cannot be monotonicity preserving, and that to construct monotonicity preserving schemes, non-linear limiter functions should be used. With this understanding, work on developing high order oscillation-free convection schemes resulted in several techniques [6–10] that can be grouped under two categories. In the first approach [11–13] a limited anti-diffusive flux is added to a first-order upwind scheme in such a way that the resulting scheme is capable of resolving sharp gradients without oscillations. In the second category, a smoothing diffusive flux is introduced into an unbounded HO scheme to damp unphysical oscillations [14–17].

Due to their multi-step nature and the difficulty in balancing the two fluxes, flux blending techniques tend to be very expensive numerically. This is why in this book two approaches for developing HR schemes falling under the flux limiter method will be presented. The first follows a composite procedure whereby high order schemes are combined with bounded low order ones, with the switch between them being controlled by a certain criterion [18]. The second method is based on adding to a diffusive first order upwind term an anti-diffusive flux multiplied by a flux limiter. In this case, the resulting HR schemes are also denoted by Total Variational Diminishing (TVD) schemes as explained in a later section.

The composite schemes approach will be presented first within the framework of the Normalized Variable Formulation (NVF) and will be visualized on a Normalized Variable Diagram (NVD). Therefore the NVF and NVD are first described. The use of the NVD will be instrumental for the definition of a criterion that ensures the boundedness of any high order interpolation scheme.

12.2 The Convection Boundedness Criterion (CBC)

A numerical scheme is expected to preserve the physical properties of the phenomenon it is trying to describe or approximate. Therefore the conditions that a bounded convection scheme should satisfy can best be understood by analyzing the physical properties of convection. Since convection transports fluid properties from upstream to downstream, then approximation to convection should possess this transportive attribute. Thus, numerical convection schemes should be upwind biased or else they will lack the convective stability. Therefore in addition to the values at the nodes straddling the interface $$ \phi_{C} $$ and $$ \phi_{D} $$, the value at the far upwind node, i.e., $$ \phi_{U} $$, is also important in analyzing advective schemes. Values at nodes farther away are less important. In the NVF presented above, values are normalized such that the effect of $$ \phi_{U} $$ is also considered. This is extremely useful as it helps identifying the conditions for which the numerical convection scheme is monotone. Whereas Spekreise’s [19] and Barth and Jespersen [20] definition of a monotone scheme (or bounded scheme) involves all neighbors surrounding the face, Leonard [21] and Gaskel and Lau [4] based their definition of monotonicity only on the neighboring points along the local coordinate system such that

(12.11)

Normalizing, the above condition becomes

(12.12)

The Convection Boundedness Criterion (CBC) for implicit steady state flow calculation developed by Gaskell and Lau states that for a scheme to have the boundedness property its functional relationship should be continuous, should be bounded from below by $$ \tilde{\phi }_{C} $$ and from above by unity, and should pass through the points (0, 0) and (1, 1), in the monotonic range $$ \left( 0 < \tilde{\phi }_{C} < 1 \right), $$ and for $$ \tilde{\phi }_{C} > 1 $$ or $$ \tilde{\phi }_{C} < 0, $$ the functional relationship $$ f\left( {\tilde{\phi }_{C} } \right) $$ should be equal to $$ \tilde{\phi }_{C} . $$ The above conditions illustrated on an NVD in Fig. 12.4, can be mathematically formulated as

(12.13)

Fig. 12.4

The Convection Boundedness Criterion (CBC) on an NVD Diagram showing the region where $$ \tilde{\phi }_{f} $$ is bounded

The Convection Boundedness Criterion is quite intuitive and can be interpreted by referring to Figs. 12.4 and 12.5. When $$ \phi_{C} $$ is in a monotonic profile the interpolation profile at the cell surface should not yield any new extremum. Thus it is constrained by the $$ \phi $$ values at the nodes straddling the face. As the value of $$ \phi_{C} $$ get closer to $$ \phi_{D} $$ while still in the monotonic regime, the value of $$ \phi_{f} $$ will also tend toward $$ \phi_{D} . $$ When $$ \phi_{C} $$ becomes equal to $$ \phi_{D} , $$ then $$ \phi_{f} $$ also becomes equal to $$ \phi_{D} $$ and thus the condition that $$ \left( {\tilde{\phi }_{C} ,\tilde{\phi }_{f} } \right) $$ passes through the point (1, 1). When the value of $$ \phi_{C} $$ is such that $$ \tilde{\phi }_{C} > 1,\,\phi_{f} $$ is assigned the upwind value, i.e., $$ \phi_{C} . $$ This has the effect of yielding the largest outflow condition possible while fulfilling the condition that $$ \phi_{f} $$ is bounded by the nodes straddling the cell face. This behavior means that any undue oscillation will be damped since $$ \phi_{C} $$ will tend to a lower value because outflow is larger than inflow in these conditions.

Fig. 12.5

Values of $$ \tilde{\phi }_{f} $$ and the Convection Boundedness Criterion

Therefore if there is no external physical mechanism to yield the extrema (a source term for example) the extrema will die out. A similar mechanism takes place when $$ \tilde{\phi }_{C} < 0. $$ However as $$ \phi_{C} $$ gets closer to $$ \phi_{U} $$ coming from the non-monotonic region, $$ \phi_{f} $$ will be equal to the upwind value $$ \phi_{C} $$ until $$ \phi_{C} = \phi_{U} $$ implying the condition that the profile of $$ \phi_{f} $$ passes through the point (0, 0). When $$ \tilde{\phi }_{C} < 0 $$ or $$ \tilde{\phi }_{C} > 1 $$ the solution will be in a region where convection is dominant and the upwind approximation will be an excellent one.

12.3 High Resolution (HR) Schemes

Constructing a bounded HO scheme, i.e., a HR scheme, using the NVD is relatively a simple exercise. Any high order base scheme can be bounded using an ad-hoc set of curves.

To construct a HR scheme, the monotonic profile in the range $$ 0 \le \tilde{\phi }_{C} \le 1 $$ should pass through the points (0, 0) and (1, 1), while remaining within the upper triangular shaded region on the NVD (Fig. 12.4). On the other hand, in the non-monotonic range, i.e., $$ \tilde{\phi }_{C} < 0 $$ and/or $$ \tilde{\phi }_{C} > 1, $$ the profile should follow the upwind profile. A number of well-known High-Resolution schemes built in this manner are illustrated in Fig. 12.6.

Fig. 12.6

NVD of several HR schemes

For improved convergence behavior, any composite HR scheme should avoid hard angles at its profile connection points as well as at its horizontal and vertical profiles. For example with the SMART scheme, which is constructed using the QUICK scheme, the convergence can be substantially improved by a minor modification to the vertical portion of its composite profile using $$ \tilde{\phi }_{f} = 3\tilde{\phi }_{C} $$ in the region $$ 0 \le \tilde{\phi }_{C} \le 1/6. $$ For the STOIC schemes the modification is applied in the $$ 0 \le \tilde{\phi }_{C} \le 1/5 $$ region. Also the horizontal portion of the composite profile for both SMART and STOIC may be slightly modified to further improve convergence. For example, one such modification is to impose a linear profile for $$ 9/10 \le \tilde{\phi }_{f} \le 1, $$ which corresponds to $$ 7/10 \le \tilde{\phi }_{C} \le 1 $$ altering the last portion of the profile to be given by $$ \tilde{\phi }_{f} = \tilde{\phi }_{C} /3 + 2/3. $$ Other modifications are also possible (e.g., one may decide to modify the horizontal portion of the composite profile in the $$ 0.95 \le \tilde{\phi }_{f} \le 1 $$ region). A similar modification can also be made for the bounded CD scheme to improve its convergence characteristics. The modified NVDs of SMART, STOIC, and SUPERBEE schemes are shown in Fig. 12.7.

Fig. 12.7

NVD of the modified SMART, STOIC, and SUPERBEE schemes

Mathematically, the functional relationships of the composite HR schemes displayed in Figs. 12.6 and 12.7 are given by

(12.14)

(12.15)

(12.16)

(12.17)

(12.18)

(12.19)

(12.20)

(12.21)

(12.22)

(12.23)

Many other schemes were developed following this methodology such as CLAM [22], UTOPIA [23], SHARP [8], and ULTRA-SHARP [24, 25], to cite a few.

Example 3

Derive the NVF form of the SMART scheme.

Solution

Starting with the QUICK scheme, we have

On the NVF diagram this looks like the black line. In order to enforce the CBC, the interpolation profile of the QUICK scheme is modified to follow the blue lines as shown in the figure below Thus the bounded QUICK scheme, now called the SMART scheme, is written as

12.4 The TVD Framework

Another popular approach for developing HR convective schemes is the Total Variation Diminishing (TVD) framework. In solving numerically an advection partial differential equation for a variable $$ \phi $$ of the form presented so far, Total Variation (TV) is defined as

(12.24)

where i represents the index of a node in the spatial solution domain. A numerical method is said to be Total Variation Diminishing (TVD) if the TV in the solution does not increase with time. Mathematically this is equivalent to

(12.25)

In his seminal paper, Harten [26] proved that a monotone scheme is TVD, and a TVD scheme is monotonicity preserving. A monotonicity preserving scheme does not create any new local extrema within the solution domain, i.e., the value of a local minimum is non-decreasing, and the value of a local maximum is non-increasing.

It is not intended here to give full mathematical derivations of the TVD approach. Rather, the intention is simply to explain the methodology for constructing TVD schemes. The approach used is based on the work of Sweby [27].

Consider the unsteady one-dimensional convection equation (11.​73), which was used in the previous chapter to study the stability of convection schemes. In the absence of diffusion and sources this equation reduces to

(12.26)

The general discretized form of the RHS term based on a five point stencil can be written as

(12.27)

where U, C, and D represent the far upstream, upstream, and downstream nodes shown in Fig. 12.1a. Sweby and Harten proved that a sufficient condition for a numerical scheme presented by Eq. (12.27) to be TVD or monotone is for the coefficients per unit mass flow rate to satisfy the inequalities

(12.28)

where the expressions for the coefficients a and b depend on the adopted convection scheme. Referring back to the convection schemes presented above, it was found that the first order upwind scheme is very diffusive while the second order central difference scheme is highly dispersive. The need is for a scheme that lies somewhere between the upwind and the central difference schemes, i.e., a scheme that has the stability of the upwind scheme and the accuracy of the central difference scheme. Such a scheme can be constructed starting from the central difference scheme written as

(12.29)

where the notation used earlier is adopted with C denoting the upwind node, D the downwind node, and f the value at the cell face straddling the C and D nodes. As implied by Eq. (12.29), the central difference scheme can be written as the sum of the upwind scheme and a flux which is supposed to be anti-diffusive since the CD scheme is dispersive. This flux is desirable as it makes the scheme second order accurate. The side effect is the unphysical oscillation it creates due to the decrease in numerical diffusion. Therefore a better approach would be one in which a portion of this anti-diffusive flux is added to the upwind scheme in such a way that the second order accuracy is preserved without creating any unphysical oscillations. One way to do that is to multiply this flux by a limiter function (also called limiter or flux limiter) that will prevent its excessive use in regions where oscillations might occur (e.g., across large gradients) while maximizing its contribution in smooth areas. Denoting such a limiter by $$ \psi \left( r \right), $$ where r is usually taken as the ratio of two consecutive gradients, $$ \phi_{f} $$ is calculated as

(12.30)

where U is the node upwind to C and D the node downwind to C. In order to preserve the sign of the anti-diffusive flux, $$ \psi \left( {r_{f} } \right) $$ is taken to be nonnegative. Therefore developing a TVD scheme reduces to finding limiters that will make the numerical scheme TVD or monotone. The conditions that these limiters have to satisfy in order for the convection scheme to be monotonicity preserving are derived next by invoking the flux limiter in the discretization of the RHS of Eq. (12.27) via the interface values given by Eq. (12.30).

Considering the one dimensional domain shown in Fig. 12.8, the convective fluxes at the element faces are given by

(12.31)

Fig. 12.8

Convective fluxes in a one dimensional domain

To simplify the derivations to follow, a positive velocity is assumed. Under these conditions, the discretized form of the RHS of Eq. (12.24) is obtained as

(12.32)

while the continuity equation is given by

(12.33)

Invoking the continuity constraint, the RHS equation can be rearranged into

(12.34)

Comparing Eq. (12.34) with Eq. (12.27), the values of a and b are found to be

(12.35)

For the scheme to be TVD, the following should hold [Eq. (12.28)]:

(12.36)

which can be expanded to

(12.37)

or simply

(12.38)

If in addition to having $$ \psi \left( r \right) \ge 0 , $$ a condition is imposed whereby $$ \psi \left( r \right) = 0 $$ for negative values of r, then the above conditions will be satisfied if

(12.39)

Combining all conditions that the limiter has to satisfy to produce a TVD scheme, a criterion similar to the CBC can be developed and is given by

(12.40)

As depicted in Fig. 12.9, these conditions can be drawn on a $$ r - \psi $$ diagram, which is also denoted by Sweby’s diagram, to show the TVD monotonicity region (blue region in the plot). Using this diagram, it is simple to grasp the formulation of TVD schemes. Any flux limiter $$ \psi \left( r \right) $$ formulated to lie within the TVD monotonicity region yields a TVD scheme. Sweby’s diagram is very similar to the NVD presented above.

Fig. 12.9

TVD monotonicity region on a $$ r - \psi $$ diagram

The limiters for all schemes presented so far can be derived and their functional relationships drawn on Sweby’s diagram. In specific the limiter of the CD is easily obtained from Eq. (12.29) as $$ \psi^{CD} \left( {r_{f} } \right) = 1 $$ while that of the SOU scheme can be computed as follows:

(12.41)

The limiters for both schemes are displayed in Fig. 12.10.

Fig. 12.10

Limiters of SOU and CD schemes on a $$ r - \psi $$ diagram

Sweby [27] also noted that because $$ \psi \left( {r_{f} } \right) = 0 $$ for $$ r_{f} < 0, $$ second order accuracy is lost at extrema of the solution. The SOU and CD schemes are second order schemes and by inspecting Fig. 12.10 it is clearly seen that both of them pass through the point (1, 1). In addition, as demonstrated in the work of Van Leer [28], any second order scheme can be written as a weighted average of the CD and SOU schemes. Thus for a scheme to be second order its limiter has to pass through the point (1, 1) and, as shown in Fig. 12.10, its limiter should lie in the region bordered by the CD and SOU limiters (blue region in the plot). The corresponding region on an NVD is shown in Fig. 12.11.

Fig. 12.11

Region on an NVD equivalent to the TVD monotonicity region on a Sweby’s diagram for second order schemes

Adopting this approach and following the procedure used with the SOU scheme, the functional relationships of the limiters for many of the HO schemes presented above can be easily computed and are given by

(12.42)

The FROMM scheme is the average of the CD and SOU scheme. Its functional relationship is mathematically written as

(12.43)

The functional relationships of these limiters are displayed in Fig. 12.12. With the exception of the upwind scheme limiter all others are seen not to be totally lying within the monotonicity region. As such these schemes are unbounded.

Fig. 12.12

High Order schemes and TVD monotonicity region on Sweby’s diagram

By limiting the $$ \psi \left( {r_{f} } \right) $$ functions of the various schemes given above to lie within the monotonicity region displayed in Fig. 12.9, these HO schemes are transformed into HR TVD schemes. Many TVD schemes have been developed in that manner and the limiters for a number of them are shown in Fig. 12.13a–d with the functional relationships of their limiters given by

(12.44)

Fig. 12.13

Limiters of the a MINMOD, b OSHER, c MUSCL, and d SUPERBEE TVD schemes on a Sweby diagram

12.5 The NVF-TVD Relation

Both NVF and TVD formulations enforce Boundedness following different approaches, which can be demonstrated to be somewhat related. This is done by first deriving a relation between $$ r_{f} $$ and $$ \tilde{\phi }_{C} , $$ then comparing the NVF-CBC (Eq. 12.13) with the TVD-CBC (Eq. 12.40), and finally presenting the general transformation that allows the functional relationship of any TVD scheme to be written in the NVF framework and vice versa.

The relation between $$ r_{f} $$ and $$ \tilde{\phi }_{C} $$ can be easily derived starting with the definition of $$ r_{f} $$ and is obtained as

(12.45)

Using Eq. (12.45) a number of linear schemes can be compared in the two frameworks. The limiter $$ \psi \left( {r_{f} } \right) = 0, $$ which represents the Upwind scheme in the TVD formulation is also equivalent to the upwind scheme in the NVF formulation (i.e., $$ \tilde{\phi }_{f} = \tilde{\phi }_{C} $$). This follows from the fact that $$ \psi \left( {r_{f} } \right) = 0 \Rightarrow \phi_{f} = \phi_{U} \Rightarrow \tilde{\phi }_{f} = \tilde{\phi }_{C} . $$ The upwind scheme is imposed as a limit for the TVD-CBC when $$ r_{f} \le 0, $$ the equivalent condition in the NVF-CBC is obtained as

(12.46)

These also represent the conditions for imposing the Upwind scheme in the NVF-CBC.

Moreover, on the NVF-CBC, the functional relationship has to increase monotonically in the region $$ 0 \le \tilde{\phi }_{C} \le 1. $$ On Sweby’s diagram the region extends over the interval $$ 0 \le r_{f} < \, {+} \infty . $$ Both regions represent the same interval as demonstrated by the following relation:

(12.47)

Further, for the TVD-CBC condition

(12.48)

the equivalent condition in the NVF-CBC can be obtained as follows:

(12.49)

Thus,

(12.50)

which is the condition that should be satisfied by the NVF-CBC. The last condition imposed by the TVD-CBC on $$ \psi \left( {r_{f} } \right) $$ is given by

(12.51)

The equivalent condition using the NVF-CBC is obtained as

(12.52)

which can be normalized to yield

(12.53)

This is more restrictive than the NVF-CBC and is the only difference between the two formulations. Based on this condition, the TVD-CBC and the modified NVF-CBC would look as shown in Fig. 12.14a with the monotonicity region reduced to the upwind line and the blue area. While the modified TVD-CBC and the NVF-CBC (i.e., the condition $$ \tilde{\phi }_{C} = 0 $$ on the NVF-CBC corresponds to $$ r_{f} = 0 $$ on the TVD-CBC) would look as shown in Fig. 12.14b. Regarding second order accuracy, it was stated that for a TVD scheme to be second order accurate it has to pass through the point (1, 1), i.e., $$ \psi \left( 1 \right) = 1. $$ The equivalent values using the NVF are found as

(12.54)

which is exactly the point Q(0.5, 0.75) found in the NFV. As stated earlier, Van Leer demonstrated that any second order scheme can be written as a weighted average of the CD and SOU schemes. Therefore its functional relationship should lie between the functional relationships of the CD and SOU schemes with their TVD-CBC monotonicity regions reduced to the upwind line and the blue area shown on a Sweby diagram and an NVD in Fig. 12.14c.

Fig. 12.14

a TVD-CBC on Sweby and Normalized Variable Diagrams. b NVF-CBC on Sweby and Normalized Variable Diagrams. c TVD-CBC on Sweby and Normalized Variable Diagrams for second order schemes

The above procedure can be generalized to transform any TVD scheme into an equivalent NVF scheme and vice versa. Starting with a scheme in the NVF framework, the value at the face $$ \phi_{f} $$ is expressed as

(12.55)

whereas for a TVD scheme $$ \phi_{f} $$ is given by

(12.56)

Equating the above two $$ \phi_{f} $$ equations, yields

(12.57)

Thus

(12.58)

The term on the left hand side of the above equation can be modified to

(12.59)

leading to

(12.60)

Equation (12.60) may also be written as

(12.61)

As an example, the functional relationship of the UPWIND Scheme in the NVF framework is $$ \tilde{\phi }_{f} = \tilde{\phi }_{C} , $$ its TVD limiter is found as

(12.62)

The TVD limiter for the DOWNWIND Scheme is $$ \psi \left( {r_{f} } \right) = 2, $$ its NVF functional relationship can be obtained as

(12.63)

Knowing the NVF form of the SOU scheme, its TVD limiter is computed as

(12.64)

The same is applicable to other schemes.

Example 4

Starting with the TVD-Van Leer formulation, derive the NVF-Van Leer scheme.

Solution

The TVD-Van Leer limiter is given by

Noting that

its TVD functional relationship is transformed to

Combining the above equation with the TVD relationship in normalized form, which is given by,

yields

The following three cases are identified:

a.

Case 1: $$ 0 < \tilde{\phi }_{C} < 1 $$

In this case $$ \left| {\tilde{\phi }_{C} } \right| = \tilde{\phi }_{C} $$ and $$ \left| {1 - \tilde{\phi }_{C} } \right| = 1 - \tilde{\phi }_{C} , $$ thus

b.

Case 2: $$ \tilde{\phi }_{C} > 1 $$

In this case $$ \left| {\tilde{\phi }_{C} } \right| = \tilde{\phi }_{C} $$ and $$ \left| {1 - \tilde{\phi }_{C} } \right| = \tilde{\phi }_{C} - 1, $$ thus

c.

Case 3: $$ \tilde{\phi }_{C} < 0 $$

In this case $$ \left| {\tilde{\phi }_{C} } \right| = - \tilde{\phi }_{C} $$ and $$ \left| {1 - \tilde{\phi }_{C} } \right| = 1 - \tilde{\phi }_{C} , $$ thus

Combining the results of the three cases into one NVF formulation, the functional relationship of the Van Leer Scheme becomes

12.6 HR Schemes in Unstructured Grid Systems

As mentioned in Chap. 11, another alternative that can be followed to overcome the hurdle of not having a clear upwind location U in unstructured grids, which is needed in the calculation of $$ \tilde{\phi }_{C} $$ or $$ r_{f} , $$ is to create a virtual one. As depicted in Fig. 12.15, the easiest way is to assume U to lie on the line joining the nodes C and D such that C is the midpoint of the segment joining the points U and D. With this assumption and based on the analysis done earlier, the following can be written:

(12.65)

from which the value of $$ \phi_{U} $$ is computed as

(12.66)

where $$ {\mathbf{d}}_{CD} $$ is the vector between the nodes C and D, and $$ {\mathbf{d}}_{UD} $$ is the vector between nodes D and the virtual node U. As mentioned above U is constructed such that C is taken to be the centre of the UD segment. With the value of $$ \phi_{U} $$ computed, the use of either the NVF or the TVD approach proceeds as described above.

Fig. 12.15

Virtual upwind node in unstructured grids

12.7 Deferred Correction for HR Schemes

The numerical implementation of HR schemes is best understood through an example. For that purpose the multi dimensional advection equation with a source is considered. Again the velocity field is assumed to be known and the conservation equation in vector form is given by

(12.67)

Integrating over the element of volume $$ V_{C} $$ shown in Fig. 12.16, applying the divergence theorem, and replacing the surface integral by a summation over the element faces, Eq. (12.67) becomes

Fig. 12.16

Two three-dimensional elements, which represent part of an unstructured grid system

(12.68)

Noticing that the mass flow rate at a cell face is given by

(12.69)

then Eq. (12.68) can be rewritten as

(12.70)

The value of $$ \phi_{f} $$ is obtained using any of the advection schemes presented earlier keeping in mind that, in order to be able to solve for the unknown values at the main nodes, the algebraic form of the discretized equation should look like

(12.71)

The difficulty lies in the instability that arises when expressing $$ \phi_{f} $$ in terms of nodal values as described next.

12.7.1 The Difficulty with the Direct Use of Nodal Values

The difficulty that arises when explicitly expressing $$ \phi_{f} $$ in terms of neighboring values will be explained by discretizing the convection flux using a TVD scheme. Referring to Fig. 12.16, the convective flux at a face f is written as

(12.72)

Substituting Eq. (12.72) into Eq. (12.70) yields

(12.73)

where

(12.74)

To see the weakness in this formulation, Eq. (12.67) is simplified to the one dimensional problem depicted in Fig. 12.8. Assuming the flow to be in the positive direction and using the terminology displayed in the figure, Eq. (12.73) becomes

(12.75)

where

(12.76)

Since $$ 0 \le \psi \left( r \right) \le 2, $$ the $$ a_{E} $$ and $$ a_{W} $$ coefficients will be of opposite signs (except for the UPWIND scheme, i.e., when $$ \psi \left( {r_{f} } \right) = 0 $$), thereby violating one of the basic rules for stability and causing convergence difficulties of the iterative procedure. Following a similar approach with the NVF leads to the same shortcomings.

A remedy, which was presented in the previous chapter, is the deferred correction (DC) procedure, in which the coefficients are based on the upwind scheme, while the difference between the HR and upwind schemes is added as a source term in the algebraic equation. The DC procedure is simple to implement and can be used in structured and unstructured grid systems, however as the difference between the cell face values calculated with the upwind scheme and that calculated with the HR scheme becomes larger, the convergence rate diminishes. This effect can be easily estimated on an NVD; the difference between the UPWIND line and that of the chosen HR scheme is the normalized difference between the cell face values. The larger this difference is, the lower the convergence rate will be. This has enticed researchers to look for other techniques for implementing HR schemes that are more implicit not affecting the convergence rate. Two of these techniques are described in the next section.

12.8 The DWF and NWF Methods

Several techniques have been developed to overcome the reduction in the convergence rate associated with the use of the Deferred Correction (DC) procedure for the implementation of HR schemes. Two of these methods are presented below, namely the Downwind Weighing Factor (DWF) method of Leonard and Mokhtari [25] (implemented in OpenFOAM®) and the Normalized Weighing Factor (NWF) method of Darwish and Moukalled [29].

The implementation details for both methods are presented in the context of solving the convection equation (Eq. 12.67) over the three-dimensional unstructured grid system shown in Fig. 12.16. The discretized equation for the element of volume $$ V_{C} $$ shown in Fig. 12.16 can be written as

(12.77)

The $$ \phi $$ values at cell faces are computed using a HR scheme and the objective of the various methods is to incorporate these values in the discretized equation in the most effective manner.

12.8.1 The Downwind Weighing Factor (DWF) Method

The Downwind Weighing Factor (DWF) [25] defined as

(12.78)

is used to rewrite the face value such that

(12.79)

thereby redistributing the HR scheme estimate $$ \phi_{f} $$ or the normalized value $$ \tilde{\phi }_{f} $$ between the Upwind and Downwind nodes. The effect is a reduced stencil for the discretized coefficients. Since the value of $$ {\phi }_{f} $$ computed using a HR scheme lies between $$ {\phi }_{C} $$ and $$ {\phi }_{D} , $$ the value of $$ DWF_{f} $$ is always between 0 and 1, i.e., $$ 0 \le DWF_{f} \le 1. $$

Now rather than computing the $$ DWF_{f} $$ explicitly from the computed $$ \phi_{f} $$ value, the $$ DWF_{f} $$ can be expressed directly from the functional relationships of the HR scheme. Table 12.1 presents such relationships for several HO and HR schemes on uniform grid.

Table 12.1

Functional relationships of the $$ DWF_{f} $$ for some HO and HR schemes on uniform grid

Scheme

Downwind weighing factor-NVF

Upwind

SOU

CD

FROMM

QUICK

Downwind

MINMOD

Bounded CD

OSHER [30]

SMART

STOIC

MUSCL

Comparing the TVD formulation given by Eq. (12.30) with Eq. (12.79), it is clear that

(12.80)

As shown in the previous section on TVD schemes, the coefficients obtained from such implementation will not be diagonally dominant and the formulation is thus not stable for many flow configurations. As the method is used in OpenFOAM®, the reasons behind the numerical difficulties that are generally experienced by the code when solving convection dominated flow problems are now clear.

For completeness, the analysis of the implementation via the DWF is presented. Starting with Eq. (12.79), the convection flux in the general case is written in the form

(12.81)

with

(12.82)

The fluxes in Eq. (12.77) can now be expressed as

(12.83)

and the discretized equation becomes

(12.84)

with

(12.85)

The coefficients in Eq. (12.85) result in a highly unstable system of equations, thus requiring substantial relaxation. This can be demonstrated on a simple one-dimensional mesh (Fig. 12.8). Without loss of generality, a positive flow field is assumed, which reduces Eq. (12.84) to

(12.86)

where

(12.87)

The continuity constraint implies that

(12.88)

thus the coefficients become

(12.89)

In the above equation the $$ a_{E} $$ and $$ a_{W} $$ coefficients have opposite signs, a violation to one of the basic coefficient rules. Furthermore for values of the DWF factors that are larger than 0.5 (i.e., $$ DWF > 0.5 $$), the diagonal coefficient $$ a_{C} $$ becomes negative resulting in a system not solvable by iterative means. This would occur whenever $$ \phi_{f} > 0.5\left( {\phi_{C} + \phi_{D} } \right) $$ a situation common to all HR schemes for $$ \phi_{C} > 0.5. $$ In fact the DWF moves much of the HR flux influence onto the downwind value causing the above mentioned issues, a situation that resembles in effect the central difference scheme.

12.8.2 The Normalized Weighing Factor (NWF) Method

The Normalized Weighing Factor (NWF) method was developed [29] to address the shortcomings of the DWF method. It operates by linearizing the normalized interpolation profile such that

(12.90)

where $$ \ell $$ and k are constants that represent the slope and intercept of the linear function within any interval of $$ \phi_{f} , $$ with the number of intervals depending on the HR scheme used. This is an exact representation for nearly all HR schemes.

For example, by equating Eq. (12.90) to the NVF form of the MINMOD scheme (Eq. 12.14), the values of $$ \ell $$ and k are deduced to be

(12.91)

In a second step Eq. (12.90) is rewritten as

(12.92)

and transformed to

(12.93)

where $$ \phi_{U} ,\,\phi_{D} , $$ and $$ \phi_{C} $$ are the values at the U, D, and C nodes whose locations depend on the flow direction. The values of $$ \ell\;{\text{and}}\;k $$ for a number of HO and HR schemes are listed in Table 12.2 (for unstructured and/or structured uniform grid).

Table 12.2

NVF values of NWF $$ \left[ {\ell, k} \right] $$ factors for some HO and HR schemes

Scheme

Uniform grid (NVF)

Upwind

SOU

CD

FROMM

QUICK

MINMOD

OSHER

MUSCL

SMART

Since for an unstructured grid the U location is virtual, the term involving $$ \phi_{U} $$ is treated in a deferred correction fashion. However the value of the resulting deferred correction source term $$ \left( {{\text{i.e.,}}\,\left( {1 - \ell - k} \right)\phi_{U} \,l \ge 0,k \ge 0} \right) $$ is smaller than the one that would be obtained with the standard deferred correction treatment (i.e., $$ \phi_{U} $$). Thus the NWF requires less under-relaxation than the standard DC method and thus allows for faster convergence.

Starting with Eq. (12.93), the convection flux in the general case (i.e., multi dimensional unstructured grid) can be written in the form

(12.94)

and linearized to yield

(12.95)

Substituting Eq. (12.95) into Eq. (12.77) the algebraic equation is obtained as

(12.96)

where now

(12.97)

The NWF was originally developed for use on structured grids with its formulation in that context allowing for a full implicit treatment of HR schemes. The full implicitness of the method on structured grid is the result of $$ \phi_{U} $$ being an actual node in the computational domain that can be resolved in the algebraic equation, which now has a larger stencil that includes the far nodes EE and WW. For the one dimensional structured grid displayed in Fig. 12.8, the NWF form of the algebraic equation becomes

(12.98)

where

(12.99)

In the NWF reformulation of the HR schemes since the value of $$ \ell $$ is greater than that of k (see Fig. 12.6), except in a narrow region of the NVD close to the Downwind line as explained next, the value of $$ a_{C} $$ is always positive and instability does not arise. Along the Downwind line of the NVD, where $$ \left( {\ell ,k} \right) = \left( {0,1} \right), $$ a value of zero for the $$ a_{C} $$ coefficient is obtained. In this case $$ \left( {\ell ,k} \right) $$ is set to $$ \left( {L,1 - L\phi_{f} } \right) $$ where L is usually set to the value of $$ \ell $$ in the previous interval of the composite scheme.

This basically allows the NWF to be much more robust than the DWF as it guarantees positive $$ a_{C} $$ coefficients.

12.8.2.1 The NWF Method in the Context of the TVD

With the exception of the MUSCL Van Leer limiter, the limiters of the TVD formulation of all HR schemes presented earlier appear as straight lines on Sweby’s diagram and as such can be written as a set of linear equations of the form

(12.100)

where m and n are constants (slope and intercept of the linear function and depend on geometric quantities only) within any interval of $$ \psi \left( {r_{f} } \right), $$ with the number of intervals depending on the HR TVD scheme used. For example, by equating Eq. (12.100) to the TVD form of the MINMOD scheme (Eq. 12.44), the values of m and n are deduced to be

(12.101)

Substituting Eq. (12.100) in Eq. (12.30), the interface value is found to be

(12.102)

where $$ \phi_{U} , \phi_{D} , $$ and $$ \phi_{C} $$ are again the values at the U, D, and C nodes whose locations depend on the flow direction. The values of m and n for a number of HO and HR schemes are listed in Table 12.3 for uniform grids. Moreover Eq. (12.102) has the same form as Eq. (12.93) with

(12.103)

Table 12.3

TVD values of NWF $$ \left[ {m,n} \right] $$ factors for some HO and HR schemes

Scheme

Uniform grid (NVF)

Upwind

SOU

CD

FROMM

QUICK

DOWNWIND

OSHER

MUSCL

SUPERBEE

Thus an approach similar to that of the NVF-NWF can be used for the implementation of the TVD-NWF.

12.9 Boundary Conditions

The Boundary conditions for the convection term are generally much simpler than for the diffusion term. The particulars of the implementation of the following boundary conditions: “Inlet”, “Outlet”, “Wall”, and “Symmetry” are now detailed.

Typical boundary elements are shown in Fig. 12.17. A boundary cell, as mentioned earlier in this book, is one that has one or more faces on the boundary. Discrete values of $$ \phi $$ are stored both at centroids of boundary cells and of boundary faces.

Fig. 12.17

Boundary elements with one or two boundary faces

Let C denotes the centroid of the boundary element with one boundary face of centroid b and of surface vector $$ {\mathbf{S}}_{b} $$ pointing outward (Fig. 12.17). As before, the discretization process over cell C of a pure convection problem in a multidimensional domain yields

(12.104)

The fluxes on the interior faces are discretized as before. Independent of the boundary condition type, the boundary flux $$ {\mathbf{J}}_{b}^{\phi ,C} $$ may be written using the boundary face centroid value as

(12.105)

such that

(12.106)

Thus the discretized equation of the boundary cell is expressed as

(12.107)

where subscript f refers to interior faces and subscript b to the boundary face. The specification of boundary conditions involves either specifying the unknown boundary value $$ \phi_{b} , $$ or alternatively, the boundary flux $$ {\mathbf{J}}_{b}^{\phi ,C} . $$ Using Eq. (12.107), the discretized equations at a boundary element for the different boundary condition types of convection problems are derived next.

12.9.1 Inlet Boundary Condition

At inlet to a domain (Fig. 12.18), the value of $$ \phi $$ is usually specified. Since the velocity field is assumed to be known, then the convective flux at inlet is also known. Therefore the boundary flux is moved to the right hand side and treated as a source term. With this modification Eq. (12.107) becomes

Fig. 12.18

Inlet boundary condition for the convection flux

(12.108)

If a HR scheme is used to discretize the convection flux at interior faces and is implemented via a deferred correction approach, then the modified algebraic equation for the boundary element can be written as

(12.109)

where

(12.110)

where F refers to interior neighboring nodes of the C grid point and f refers to interior faces of the boundary element.

12.9.2 Outlet Boundary Condition

At outlet from the domain (Fig. 12.19) no information downstream of the boundary grid point is available. However, being a directional phenomenon, the value of $$ \phi $$ at the boundary is highly dependent on upstream locations. In fact, the upwind and SOU schemes, for example, do not require any information at outlet since its value can be expressed as a function of values at upstream nodes. The treatment that has proven to be very effective at an outlet boundary condition is to assume the $$ \phi $$ profile to be fully developed, which is equivalent to assuming that the normal gradient to the face is zero [i.e., $$ \left( {\nabla \phi \cdot {\mathbf{n}}} \right)_{b} = \left( {\partial \phi /\partial n} \right)_{b} = 0 $$]. The usual practice at an outlet (Fig. 12.19) is to apply the upwind scheme $$ \left( {\phi_{b} = \phi_{C} } \right), $$ which automatically results in a zero normal gradient.

Fig. 12.19

Outlet boundary condition for the convection flux

Discretizing the convection flux at interior faces using a HR scheme implemented through a deferred correction approach, the modified algebraic equation for the boundary element can be written as

(12.111)

where

(12.112)

where f refers to the interior faces of the boundary element, and C and F refer to owner and neighbor, respectively.

12.9.3 Wall Boundary Condition

As shown in Fig. 12.20, the normal velocity at a wall is zero. As such the convection flux is zero and does not appear in the algebraic equation.

Fig. 12.20

Wall boundary condition for the convection flux

Again adopting a HR scheme with a deferred correction approach, the modified algebraic equation for the boundary element can be written as

(12.113)

where

(12.114)

Again f refers to the interior faces of the boundary element and C and F refer to the owner and neighbor nodes, respectively.

12.9.4 Symmetry Boundary Condition

No flow crosses a symmetry boundary. Therefore it is treated in a similar fashion to a wall boundary condition with the convection flux normal to a symmetry boundary set to zero.

12.10 Computational Pointers

12.10.1 uFVM

Similar to HO schemes discussed in Chap. 11, HR schemes are implemented in uFVM using the deferred correction method. The main difference in the implementation stems from the use of the NVF or TVD relations rather than the calculation of the face value using directly the gradient. The implementation of the STOIC HR [31] scheme using the NVF formulation is shown in Listing 12.1 (cfdAssembleConvectionTermDCSTOIC).

Listing 12.1

Implementation of the STOIC HR scheme

It starts with the retrieval of the needed fields, followed by setting the upwind and downing indices for all interior faces. Then for each face, $$ \phi_{C} $$ and $$ \phi_{D} $$ are identified, $$ \phi_{U} $$ is constructed, and $$ \tilde{\phi }_{C} $$ is computed and used to calculate the face value from the NVF relationship of the adopted HR scheme. Finally $$ \phi_{f} $$ is reconstructed from $$ \tilde{\phi }_{f} $$ and used in the deferred correction method.

12.10.2 OpenFOAM®

As discussed in Chap. 11 the discretization of the convection term in OpenFOAM® [32] is accomplished through the base class surfaceInterpolationScheme. This class is inherited by any face interpolation algorithm. High resolution schemes, as discussed in this chapter, are special face interpolation algorithms. Thus, as displayed in Fig. 12.21, OpenFOAM® groups all TVD schemes in a base class, derived from the surfaceInterpolationScheme class, denoted by the limitedSurfaceInterpolationScheme class.

Fig. 12.21

UML showing the base class that groups all TVD schemes

As shown in Listing 12.2, this class consists of the following three main functions: the virtual weights function representing the main virtual function of the surfaceInterpolationScheme class, a local weights function defined with three arguments, and a new virtual base function called limiter.

Listing 12.2

The limitedSurfaceInterpolationScheme class showing its three main functions

The script of the virtual weights function, shown in Listing 12.3, is given by

Listing 12.3

Script showing the implementation of the virtual weights function

It is clear that executing the script instantiates the additional local weights function. The three main arguments of the local weights function are the flux phi, the linear interpolation weights (representing the central differencing weights), and the returning object of the virtual base class limiter. These are clearly shown in Listing 12.4 where the local weights function is defined.

Listing 12.4

Script showing the implementation of the local weights function

The calculation of the interpolation weights according to the TVD formulation implemented in Listing 12.4 may seem, from a first look, a bit unclear. Confusion may be eliminated by considering the case of a positive flux, for example, for which the weight $$ \varpi $$ is calculated as

(12.115)

For a uniform grid $$ \varpi_{CD} = 1/2 $$ yielding

(12.116)

Recalling Eq. (11.​164) and substituting the weight yields

(12.117)

which is Eq. (12.30) in the TVD formulation.

So far the implementation of HR schemes in OpenFOAM® following the TVD formulation has been discussed along with its integration in the standard convection discretization procedure by properly defining the interpolation weights. Due to the many TVD schemes that can be used, OpenFOAM® has introduced a base virtual function denoted by limiter for the implementation of these schemes. The last step of the computational pointer is to describe how this class is defined and which classes, this limiter base class, engage.

All TVD limiters are organized through a class named LimitedScheme that inherits and defines the limiter function of the limitedSurfaceInterpolationScheme class. The definition of this class is based on nested template classes definition in which the derived class is described with a template argument, as shown in Listing 12.5.

Listing 12.5

The LimitedScheme class with the Limiter template

Here Limiter is not a function but just a template definition. Additionally the virtual limiter class is now specialized (Listing 12.6).

Listing 12.6

The virtual limiter class

As depicted in Listing 12.7 the definition of the limiter function is practically linked to an auxiliary function named calcLimiter.

Listing 12.7

The script used to call the calcLimiter function

The core of the calcLimiter function is to evaluate the TVD limiter and to store it in the tlimiterField, as shown in Listings 12.7 and 12.8.

Listing 12.8

Script used with the calcLimiter function

In the calcLimiter function the following steps are performed:

Storing a copy of the field to be interpolated in lPhi

Evaluating the gradient of the lPhi field using fvc::grad(lPhi)

Collecting the central differencing weights

Collecting the cell centers

Evaluating the limiter by calling the nested template class: pLim[face] = Limiter::limiter.

As an example of a Limiter::limiter function, the TVD formulation of the SUPERBEE given in Eq. (12.44) is considered. The OpenFOAM® definition can be found in “$FOAM_SRC/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/SuperBee/SuperBee.H” file. In this case the script of the limiter function is given in Listing (12.9) as

Listing 12.9

The limiter function of the SuperBee scheme

where the arguments are as stated before including the gradients, the central differencing weights, etc., while the returned value follows exactly Eq. (12.44).

The r definition follows the same nested template class and the function itself is defined in the file “$FOAM_SRC/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/NVDTVD.H” according to Eq. (12.66). The implementation details are given in Listing 12.10.

Listing 12.10

Script used to calculate r

12.11 Closure

The chapter dealt with the bounding of HO convection schemes. This was accomplished by enforcing a convection boundedness criterion (CBC). The resulting HO bounded schemes were denoted by HR schemes. The Normalized Variable Formulation (NVF) and Total Variation Diminishing (TVD) approaches were introduced as frameworks for the development of HR schemes. Two techniques for the implementation of HO and HR schemes in structured and unstructured grids were introduced, namely the Downwind Weighing Factor (DWF) method and the Normalized Weighing Factor (NWF) method. The next chapter is devoted to the discretization of the unsteady term.

12.12 Exercises

Exercise 1

a.

Starting with the NVF form of the SMART scheme derive its equivalent TVD form.

b.

Starting with the TVD form of the OSHER scheme derive its equivalent NVF form.

Exercise 2

For non-uniform grids the equations for the various schemes become geometry dependent. This is also true for the point Q through which schemes have to pass to be second order accurate.

Find the coordinates of Q in the general case of a non-uniform grid.

Hint: define a normalized space variable as [33]

Exercise 3

Derive the $$ DWF_{f} $$ and $$ NWF_{f} $$ relationships of the OSHER and SMART schemes.

Exercise 4

For the one dimensional uniform mesh shown in Fig. 12.22, use the NVF-SMART, NVF-OSHER, QUICK, and SOU schemes to compute $$ \phi_{f} $$ for the following situations:

Fig. 12.22

A one dimensional uniform grid

a.

b.

c.

d.

Exercise 5

For the one dimensional mesh shown in Fig. 12.22, use the TVD-VanLeer and TVD-MINMOD schemes to compute $$ \phi_{f} $$ for the following situations:

a.

b.

c.

d.

Exercise 6

Consider the steady transport of a scalar $$ \phi $$ in the domain shown in Fig. 12.23. The governing conservation equation is given by

where $$ \rho = 1, $$ $$ {\mathbf{v}} = 2yx^{2} {\mathbf{i}} - 2{xy^{2}} {\mathbf{j}}, $$ and $$ \Delta x =\Delta y = 1/3. $$

Fig. 12.23

Convection of a two dimensional scalar field

a.

Using the NVF-SMART scheme, applied via a deferred correction approach, discretize the equation over the computational domain and find the value of $$ \phi $$ at each element centroid.

b.

Using the TVD-SMART scheme, applied via a deferred correction approach, discretize the equation over the computational domain and find the value of $$ \phi $$ at each element centroid.

c.

Using the NVF-SUPERBEE applied via the NVF-NWF method setup the system of equations over the domain.

d.

Using the TVD-MUSCL applied via the TVD-DWF method setup the system of equations over the domain.

Exercise 7

The advection of a step profile in an oblique velocity field, $$ {\mathbf{v}} = 2{\mathbf{i}} + {\mathbf{j}}, $$ shown in Fig. 12.24 is governed by

Fig. 12.24

Advection of a step profile in an oblique velocity field

For different grid sizes, setup the problem and solve it in OpenFOAM® and uFVM using the following HR advection schemes assuming unit dimensions in x and y directions, and compare results with the exact solution $$ {\left( {\rho = 1} \right)}{:} $$

a.

MINMOD

b.

OSHER

c.

SMART

Exercise 8

The Smith-Hutton test governed by

and illustrated in Fig. 12.25, involves the pure advection of a step profile in a rotational velocity field described as

Fig. 12.25

Advection of a step profile in a two dimensional rotational velocity field

For different grid sizes, solve the test in OpenFOAM® and uFVM using the following advection schemes, and compare results with the exact solution $$ {\left( \rho = 1 \right)}{:} $$

a.

Bounded CD

b.

MUSCL

c.

SUPERB

Exercise 9

a.

Using Doxygen [34] list all the derived classes of the class limitedSurfaceInterpolationScheme<Type>.

b.

Verify the correct implementation of the derived upwind<Type> class: check the weights function.

c.

Find all OpenFOAM® limiter classes listed in Eq. (12.44) (vanLeerLimiter). Compare the formula with the OpenFOAM® implementation.

References

1.

Leonard BP (1988) Universal limiter for transient interpolation modeling of the advective transport equations: the ULTIMATE conservative difference. NASA TR-100916, ICOMP-88-11

2.

Leonard BP (1987) SHARP simulation of discontinuities in highly convective steady flow. NASA TM-100240

3.

Leonard BP, Lock AP, MacVean MK (1995) Extended numerical integration for genuinely multidimensional advective transport insuring conservation. In: Proceedings of the ninth international conference numerical methods in laminar and turbulent flows, vol 9(1), pp 1–12

4.

Gaskell PH, Lau AKC (1988) Curvature compensated convective transport: SMART, a new boundedness preserving transport algorithm. Int J Numer Meth Fluids 8(6):617–641MATHMathSciNetCrossRef

5.

Godunov S, Ryabenki V (1963) Spectral stability criteria for boundary value problems for non self-adjoint difference equations. Uspekhi Mat Nauk 18:1–12MATH

6.

Fromm EA (1968) A method for reducing dispersion in convective difference schemes. J Comput Phys 3:176–189MATHCrossRef

7.

Sheu TWH, Wang SK, Tsai SF (1998) Development of a high-resolution scheme for a multi-dimensional advection-diffusion equation. J Comput Phys 144(1):1–16CrossRef

8.

Leonard BP, Niknaffs HS (1991) Sharp monotonic resolution of discontinuities without clipping of narrow extrema. Comput Fluids 19:141–154MATHCrossRef

9.

Van Leer B (1977) Towards the ultimate conservation difference scheme V. A second order sequel to Godunov’s method. J Comput Phys 23:101–136

10.

Zhu J, Rodi W (1991) A low-dispersion and bounded convection scheme. Comput Methods Appl Mech Eng 92:87–96MATHCrossRef

11.

Yee HC, Warming RF, Harten A (1983) Implicit total variation diminishing (TVD) schemes for steady-state calculations. NASA Technical Memorandum 84832

12.

Sweby PK (1984) High resolution schemes using flux limiters for hyperbolic conservation laws. SIAM J Numer Anal 21(5):995–1011MATHMathSciNetCrossRef

13.

Chakravarth SR (1987) Development of upwind schemes for the Euler equations. NASA Contractor Report 4043

14.

VanderHeyden WB, Kashiwa BA (1998) Compatible fluxes for Van Leer advection. J Comput Phys 146:1–28MATHMathSciNetCrossRef

15.

Boris JP, Book DL (1973) Flux-corrected transport: I. SHASTA, a fluid transport algorithm that works. J Comput Phys 11:38–69MATHCrossRef

16.

Kuzmin D, Turek S (2002) Flux correction tools for finite elements. J Comput Phys 175:525–558MATHMathSciNetCrossRef

17.

Zalesak S (1979) Fully multidimensional flux corrected algorithm for fluid. J Comput Phys 31:335–362MATHMathSciNetCrossRef

18.

Leonard BP (1988) Simple high-accuracy resolution program for convective modelling of discontinuities. Int J Numer Meth Eng 8:1291–1318MATHCrossRef

19.

Spekreise S (1987) Multigrid solution of monotone second order discretizations of hyperbolic conservation laws. Math Comput 49(179):135–155CrossRef

20.

Barth T, Jespersen DC (1989) The design and application of upwind schemes on unstructured meshes. AIAA paper 89-0366

21.

Leonard BP (1991) The ULTIMATE conservative difference scheme applied to unsteady one-dimensional advection. Comput Methods Appl Mech Eng 88(1):17–74MATHCrossRef

22.

Dritschel DG, Fontane J (2010) The combined Lagrangian advection method. J Comput Phys 229:5408–5417MATHMathSciNetCrossRef

23.

Leonard BP, MacVean MK, Lock AP (1993) Positivity-preserving numerical schemes for multidimensional advection. Technical Memorandum TM-106055 ICOMP-93-05, NASA

24.

Leonard BP (1988) Simple high-accuracy resolution program for convective modelling of discontinuities. Int J Numer Meth Fluids 8:1291–1318MATHCrossRef

25.

Leonard BP, Mokhtari S (1990) Beyond first-order upwinding: the ULTRA-SHARP alternative for non-oscillatory steady state simulation of convection. Int J Numer Methods Eng 30:729–766CrossRef

26.

Harten A (1983) High resolution schemes for hyperbolic conservation laws. J Comput Phys 49:357–393MATHMathSciNetCrossRef

27.

Sweby PK (1984) High resolution schemes using flux limiters for hyperbolic conservation laws. SIAM J Numer Anal 21(5):995–1011MATHMathSciNetCrossRef

28.

Van Leer B (1974) Towards the ultimate conservative difference scheme, 11. Monotonicity and conservation combined in a second order scheme. J Comput Phys 14:361–370MATHCrossRef

29.

Darwish M, Moukalled F (1996) The normalized weighting factor method: a novel technique for accelerating the convergence of high-resolution convective schemes. Numer Heat Transf, Part B: Fundam 30:217–237CrossRef

30.

Osher S (1984) Shock modeling in transonic and supersonic flow. In: Habashi WG (ed) Recent advances in numerical methods in fluids, 4. Advances in computational transonics. Pineridge Press, Swansea

31.

Darwish MS (1993) A new high-resolution scheme based on the normalized variable formulation. Numer Heat Transf, Part B: Fundam 24(3):353–371CrossRef

32.

OpenFOAM, 2015 Version 2.3.x. http://​www.​openfoam.​org

33.

Darwish M, Moukalled F (1994) Normalized variable and space formulation methodology for high-resolution schemes. Numer Heat Transf, Part B 26(1):79–96CrossRef

34.

OpenFOAM Doxygen, 2015 Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_13

13. Temporal Discretization: The Transient Term

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

The discussions in previous chapters assumed steady state conditions, which did not require the discretization of the transient term. Accounting for transient phenomena adds a new dimension to the problem. However since transient variations are parabolic by nature, there is no need to define a field in the time dimension, as is the case for the spatial domain. In general only one or two additional variable fields, or time levels, are stored (depending on the numerical order of the selected scheme). Another difference with steady state configurations is that transient systems are modeled using a time stepping procedure. Starting with an initial condition at time $$ t = t_{0} $$, the solution algorithm marches forward and finds a solution at time $$ t_{1} = t_{0} +\Delta t_{1} $$. The solution found is the initial condition for the next time step and is used to obtain the solution at time $$ t_{2} = t_{1} +\Delta t_{2} $$. The process is repeated until the required time is reached. The focus of this chapter is on techniques used for the discretization of the transient term. Two approaches for developing transient schemes are presented. In the first one Taylor expansions are used to express the transient term with the aid of nodal values. This is in effect a finite difference discretization. In the second approach the finite volume method is used on a pseudo time element in a similar fashion to what was done to the convection term. Several transient schemes are presented and their characteristics discussed.

13.1 Introduction

For transient simulations, the governing equations are discretized in both space and time. While the spatial discretization is performed in the spatial domain as was done for the steady-state case, the temporal discretization involves setting up a time coordinate along which the derivative (for the finite difference method) or the integral (for the finite volume method) of the transient term is evaluated (Fig. 13.1).

Fig. 13.1

Time coordinate, transient, and spatial operators

In general, the expression for the transient behavior, or time evolution, of a variable ϕ is governed by an equation of the form

(13.1)

where the function $$ {\mathcal{L}}\left( \phi \right) $$ is a spatial operator that includes all non-transient terms (convection, advection, sources, etc.) and $$ \partial \left( {\rho \phi } \right)/\partial t $$ is the transient operator, both displayed in Fig. 13.1.

Integrating Eq. (13.1) over an element C (Fig. 13.2) yields

(13.2)

which, after a spatial discretization about the volume centroid, becomes

(13.3)

where $$ V_{C} $$ is the volume of the discretization element and $$ L\left( {\phi_{C}^{t} } \right) $$ is the spatial discretization operator expressed at some reference time t, which can be written in algebraic form as

(13.4)

In Eq. (13.3) the steady state discrete equation is recovered when $$ t \to \infty $$. This is also true when steady state is reached through time marching, i.e., when $$ \phi_{C}^{{t +\Delta t}} = \phi_{C}^{t} $$. This guarantees that the solution obtained when steady state is reached is the same as the one that would have been obtained with the problem solved directly as a steady state one.

Fig. 13.2

Spatial element

For the discretization of the transient term, the practice traditionally has been to follow a finite difference approach [1–3], whereby a Taylor series expansion of $$ \partial \left( {\rho \phi } \right)/\partial t $$ is used to express the derivative in terms of the discrete nodal values. In this chapter, another procedure that is more in line with the finite volume approach will also be presented. In this context, $$ \partial \left( {\rho \phi } \right)/\partial t $$ is integrated over a temporal element [4] and transformed into face fluxes in a similar fashion to what was done with convection schemes, except that the discretization is now performed along the transient axes.

13.2 The Finite Difference Approach

Since in the transient space the grid is structured (Fig. 13.3), it has been quite common to treat the transient term using the finite difference method. In this approach, the spatial operator, $$ L\left( \phi \right) $$, is discretized at time t, while the transient derivative is evaluated using a combination of Taylor expansions about time t resulting in a variety of transient schemes, some of which are described next.

Fig. 13.3

Structured transient finite difference grid

13.2.1 Forward Euler Scheme

To evaluate the transient term, a Taylor expansion of the derived quantity about a time direction is needed. In this first case, the expansion is performed in a forward manner about time t. That is for some function T, its value at time $$ t +\Delta t $$ is expressed using a Taylor series in terms of the values of T and its derivates at time t as

(13.5)

Truncating the series starting with terms of order $$ \Delta t^{2} $$, the first derivative can be formulated as

(13.6)

This is now a first order discretization since the equation was divided by $$ \Delta t $$ to yield the gradient approximation. Replacing T by $$ \left( {\rho \phi } \right) $$ in Eq. (13.6) and substituting the resulting expression for the derivative in Eq. (13.3), the discretized equation becomes

(13.7)

The transient stencil for Eq. (13.7) shown in Fig. 13.4, indicates that the computation of $$ \left( {\rho_{C} \phi_{C} } \right) $$ at time $$ t +\Delta t $$ does not require solving a system of equations. Rather, values of $$ \phi_{C} $$ at time $$ t +\Delta t $$ can be computed explicitly based on values from the previous time step since all spatial terms are evaluated at the old time t. The resulting scheme belongs to the class denoted by explicit transient schemes [5–12]. The main characteristic of all explicit transient schemes is their capability of generating solutions by marching in time without the need to solve a system of equations at each time level. This provides a high computational efficiency and simplifies the parallelization of the computational mesh. Yet only few commercial codes have adopted this approach and for an important reason related to a limitation on the size of $$ \Delta t $$, which will be discussed in the next section.

Fig. 13.4

The explicit Euler stencil

Substituting the discretized algebraic relation of the spatial operator into Eq. (13.7), the complete algebraic equation is obtained as

(13.8)

where

(13.9)

In the above equations $$ a_{C}^{{t +\Delta t}} $$ and $$ a_{C}^{t} $$ are the diagonal coefficients resulting from the discretization of the transient term, $$ \phi_{C}^{{t +\Delta t}} $$ and $$ \phi_{C}^{t} $$ are the values at time levels $$ t +\Delta t $$ and t, respectively, and $$ a_{C} $$, $$ a_{F} $$, and $$ b_{C} $$ are the coefficients obtained from the spatial discretization.

To simplify notation, throughout this chapter variables referring to values obtained at a previous time step will be denoted with a superscript ° and variables referring to values obtained two time steps earlier will be denoted with a superscript °°. On the other hand no superscript will be used to denote variables at the current time step except for the coefficient of the unsteady term multiplying $$ \phi_{C} $$, which will be denoted with the superscript $$ ^{ \bullet } $$. Adopting the new notation, Eqs. (13.8) and (13.9) become

(13.10)

where

(13.11)

Equation (13.10) can be re-arranged into

(13.12)

clearly showing that values of ϕ at the current time step are computed via an explicit relation without solving a system of equations.

13.2.2 Stability of the Forward Euler Scheme

The convergence and stability of numerical schemes was initially addressed by Courant, Friedrichs, and Lewy [13]. They showed that in order for the solution of a difference equation to converge to the solution of the partial differential equation the numerical scheme must use all the information contained in the initial data that influence the solution. This requirement has become later known as the CFL condition.

In reality the CFL condition can be interpreted simply as one of the basic rules that should be satisfied by the coefficients, namely the opposite signs rule extended to include the transient coefficients. Thus just as $$ \phi_{F} $$ is considered a ‘spatial’ neighbor of $$ \phi_{C} $$, $$ \phi_{C}^{ \circ } $$ is a ‘temporal’ neighbor of $$ \phi_{C} $$, and the opposite signs rule should equally apply to both. Noting that the diagonal coefficient is now $$ a_{C}^{ \bullet } $$ and the coefficient of its ‘temporal’ neighbor is $$ \left( {a_{C} + a_{C}^{ \circ } } \right) $$, the opposite signs requirement becomes

(13.13)

13.2.2.1 Stability of a Transient-Advection Case

For the one dimensional pure advection problem with a flow moving right wise shown in Fig. 13.5, the $$ a_{C} $$ and $$ a_{C}^{ \circ } $$ coefficients in the discretized equation of element C, using the upwind scheme for the interpolation of all variables at an element face, are given by

(13.14)

Therefore, the CFL condition requires

(13.15)

or

(13.16)

For convection dominated flows, defining a CFL number as

(13.17)

implies that for numerical stability the CFL number should satisfy

(13.18)

Fig. 13.5

A portion of the discretized domain for a one dimensional convection problem

13.2.2.2 Stability of a Transient-Diffusion Case

For pure diffusion problems, the expression for the CFL number is different. For that purpose, the one dimensional pure diffusion problem schematically depicted in Fig. (13.6) is considered.

Fig. 13.6

A portion of the discretized domain for a one dimensional diffusion problem

The $$ a_{C} $$ and $$ a_{C}^{ \circ } $$ coefficients in the discretized equation of element C using linear interpolation profiles are given by

(13.19)

Therefore, the CFL condition requires

(13.20)

or

(13.21)

For the case when the grid is uniform and the diffusion coefficient is constant, Eq. (13.21) becomes

(13.22)

For diffusion dominated problems, a CFL number is defined as

(13.23)

implying that for stability the following condition should be satisfied:

(13.24)

13.2.2.3 Stability of a Transient-Convection-Diffusion Case

For the case of a multi dimensional unsteady convection and diffusion problem (Fig. 13.7) and based on the derivations presented in Chap. 12, the coefficients in Eq. (13.14) are given by

(13.25)

Substituting the expressions for the coefficients from Eq. (13.25) in Eq. (13.13), the CFL condition becomes

(13.26)

leading to the following constraint on the time step:

(13.27)

Equation (13.27) is the general requirement for stability of explicit transient schemes. In fact the conditions obtained earlier for pure convection and pure diffusion in one dimensional domains can be derived as special cases of Eq. (13.27). For the case of a one dimensional diffusion problem with a uniform grid of cell size $$ \Delta x $$, constant density $$ \rho $$, and a uniform diffusion coefficient $$ \Gamma ^{\phi } $$, Eq. (13.27) reduces to

(13.28)

While for the case of a one dimensional advection problem discretized using the upwind scheme and with the flow moving from left to right, Eq. (13.27) reduces to

(13.29)

This stability constraint is stringent and very restrictive as it forces the use of extremely small time steps when solving transient problems. That is, whereas the computational cost at each time step is small in comparison to what would be required to solve a system of equations at that level, the imposed limitation by the CFL condition necessitates a larger number of steps to move the solution in time. Therefore the benefit of reducing the calculations per time step is lost by the much larger number of time steps required. Moreover, Eq. (13.27) indicates also that improving the spatial accuracy by decreasing the grid size, decreases further the maximum time step size that can be used without causing instabilities.

Fig. 13.7

A portion of the discretized domain for a multi dimensional convection problem

As shown next, such a constraint does not apply to implicit schemes for which the transient term has always the proper sign.

13.2.3 Backward Euler Scheme

To derive the backward Euler scheme, the value of the function T at time $$ t - \Delta t $$ is expressed using a Taylor series using the values of T and its derivates at time t as

(13.30)

Manipulating Eq. (13.30), an equation for the first derivative is obtained as

(13.31)

Replacing T by $$ \left( {\rho \phi } \right) $$ in Eq. (13.31) and substituting the resulting expression for the derivative in Eq. (13.3), the discretized equation becomes

(13.32)

Then invoking the algebraic relation of the spatial operator and the suggested notation, the complete algebraic form of the transient scalar equation is obtained as

(13.33)

with the coefficients given by

(13.34)

The stencil for Eq. (13.33) is shown in Fig. 13.8. It is clear that with the spatial operator evaluated at the same time level as the new temporal coefficient, resolving the ϕ field at a new time level requires solving a system of equations. This type of schemes requiring the solution of a system of equations is denoted by implicit schemes [5–12].

Fig. 13.8

Stencil for the backward Euler stencil

As can be inferred from Eq. (13.34) $$ a_{C} $$ and $$ a_{C}^{ \circ } $$ are of opposite signs guaranteeing that $$ \phi_{C} $$ is bounded by the values of its spatial neighbors at the current time step t and by the value of its temporal neighbor at the previous time step $$ t -\Delta t $$. This implies that the scheme is always stable independent of the time step used, allowing for the solution to proceed rapidly by using large time steps. Nonetheless this is not the ideal scheme as it is of low order and solutions obtained with this scheme are of low accuracy unless small time steps are used, which puts its use in a quandary. Adopting large time steps for computational efficiency results in a solution of low accuracy and using small time steps for higher accuracy is associated with low computational efficiency.

13.2.4 Crank-Nicolson Scheme

In the Crank-Nicolson scheme [2, 14] a more accurate representation of the transient term is derived by expressing the values of the function T at times $$ t -\Delta t $$ and $$ t +\Delta t $$ in terms of the values of T and its derivates at time t as

(13.35)

Then, subtracting $$ T\left( {t +\Delta t} \right) $$ from $$ T\left( {t -\Delta t} \right) $$ given in Eq. (13.35), an equation for the first derivative is obtained as

(13.36)

Note that the order of accuracy of the derivative is now $$ O\left( {\Delta t^{2} } \right) $$ since the second order derivative is completely eliminated.

Substituting the time derivative given by Eq. (13.36) into Eq. (13.3) yields

(13.37)

Then invoking the algebraic relation of the spatial operator, and using the suggested notation, the complete algebraic form of the transient scalar equation is obtained as

(13.38)

with the coefficients given by

(13.39)

The stencil for Eq. (13.38) is shown in Fig. 13.9. It is clear that the scheme is an explicit type scheme, since the evaluation of $$ \left( {\rho \phi } \right)^{{t +\Delta t}} $$ can be performed using only old values. However two old levels are now needed, with the spatial operator being evaluated at one of these levels.

Fig. 13.9

Stencil of the Crank Nicholson Scheme

An analysis of the stability of the CN scheme can be performed after slightly modifying the original equation. Using the following approximation:

(13.40)

the algebraic equation [Eq. (13.38)] becomes

(13.41)

Thus, the stability condition becomes

(13.42)

For the one dimensional transient advection problem displayed in Fig. 13.5, Eq. (13.42) results in

(13.43)

where it has been assumed that the advection term is discretized using the upwind scheme. Using the CFL number for convection defined above, Eq. (13.43) is expressed as

(13.44)

The larger CFL limitation is pleasing, but the improved accuracy is just more important as it allows for accurate solutions to be achieved without the need to resort to very small time steps, especially that the second order derivative is now eliminated from the error. More details on accuracy analysis will be presented in later sections.

13.2.5 Implementation Details

The CN scheme can also be derived by summing the Forward and Backward transient Euler schemes [4], as shown next.

(13.45)

(13.46)

Forward Euler + Backward Euler:

(13.47)

This formulation points to a simple implementation of the CN scheme within an implicit scheme framework as a two-step procedure. In the first step a Backward Euler formulation is used to implicitly find $$ \left( {\rho \phi } \right)^{t} $$ from

(13.48)

while in the second step the CN value at time step $$ t +\Delta t $$ is found explicitly as

(13.49)

In this derivation it was assumed that the transient time step $$ \Delta t $$ is divided into two equal local time steps $$ \left( {\Delta t_{local} } \right) $$, with $$ \Delta t_{local} $$ equals half the set time step $$ \Delta t $$.

It is important to note that while the CN scheme is second order accurate, it is still an explicit scheme, which is constrained by a CFL like condition, as explained above.

13.2.6 Adams-Moulton Scheme

The development of the second order Adams-Moulton scheme [15, 16] requires expanding the values of T at $$ t -\Delta t $$ and $$ t - 2\Delta t $$ using Taylor series expansions around t, yielding

(13.50)

The first derivative is obtained by combining the two equations in such a way that the second order derivative is eliminated, resulting in the following equation:

(13.51)

which, upon substituting in Eq. (13.3), yields

(13.52)

Expanding the spatial term, the final form of the algebraic equation is obtained as

(13.53)

with the coefficients given by

(13.54)

It is clear that the $$ a_{C}^{ \circ \circ } $$ coefficient has a positive sign implying that an increase in $$ \phi_{C}^{ \circ \circ } $$ would lead to a decrease in $$ \phi_{C} $$. This is mitigated by the large $$ a_{C}^{ \circ } $$ coefficient, which has the right influence. Thus while the scheme is stable, it is not bounded with unphysical oscillations expected in certain circumstances.

Example 1

The thermal conductivity of a solid sphere of volume 1 m³ is so high that its resistance to conduction is very small as compared to its resistance to convection heat transfer with the surroundings. Thus temperature gradients within the sphere are negligible and the temperature of the sphere is spatially uniform at any instant. The initial temperature of the sphere is $$ T_{h} $$ and that of the surroundings is $$ T_{\infty } $$ . The density, specific heat, sphere surface area, and convection heat transfer coefficient with the surroundings are ρ, c, A s , and $$ h_{\infty } $$ , respectively. Neglecting heat transfer by radiation, the energy equation for the sphere is given by

Defining a dimensionless temperature as

the energy equation and initial condition become

For a value of $$ h_{\infty } A_{S} /\rho cV = 1 $$, compare dimensionless temperature values obtained analytically with numerical ones generated using the first order explicit scheme, the first order implicit scheme, and the second order CN scheme applied via the two-step procedure at times 0.1, 0.2, and 0.3 using a time step with size of 0.1.

Solution

The governing equation reduces to

subject to

By separation of variables and application of the initial condition the analytical solution is found as

Thus the analytical solution at times 0.1, 0.2, and 0.3 are given by

The numerical solution is obtained with V = 1, $$ L\left( {\phi^{n} } \right) = - \phi^{n} $$, and $$ L\left( {\phi^{n + 1} } \right) = - \phi^{n + 1} . $$

The error in the numerical solution is found using

Numerical solution using the first order explicit scheme

Numerical solution using the first order implicit scheme

Numerical solution using the second order CN scheme

In this case the solution is obtained using Eqs. (13.48) and (13.49) that are reduced to

where the total time step $$ \Delta t $$ has been divided into two equal time steps of value $$ \Delta t/2 $$. Applying the above equations, the solutions are found as

13.3 The Finite Volume Approach

The Finite Volume approach for the discretization of the transient term is very similar to the discretization of the convective term [4], except that the integration is carried over temporal rather than spatial element (Fig. 13.10).

Fig. 13.10

Element in the transient domain

Integration of Eq. (13.3) over the time interval $$ \left[ {t -\Delta t/2,\,t +\Delta t/2} \right] $$ yields

(13.55)

With $$ V_{C} $$ treated as a constant, Term I turned into a difference of face fluxes, and Term II evaluated as a volume integral using the mid point rule, Eq. (13.55) becomes

(13.56)

Equation (13.56) is the semi-discretized transient equation, which can be written in the more standard form by dividing all terms by the temporal element volume, $$ \Delta t $$, leading to

(13.57)

To derive the full discretized equation, an interpolation profile expressing the face values at $$ \left( {t -\Delta t/2} \right) $$ and $$ \left( {t +\Delta t/2} \right) $$ in terms of the element values at $$ \left( t \right) $$, $$ \left( {t -\Delta t} \right) $$, etc., is needed. The selection of this profile can heavily rely on the understanding gained from the discretization of the convection term. The choice will obviously affect the accuracy and robustness of the method. In that regard, it is worth mentioning that the integration of the spatial operator is second order in time, but the accuracy of the operator itself is determined by the options used during its discretization.

Independent of the profile used, the flux will be linearized based on old and new values as

(13.58)

where again superscript ° refers to old values. With the linearization completed, the coefficients of the algebraic equation can then be assembled into

(13.59)

In what follows the discretization for a number of interpolation profiles is presented.

13.3.1 First Order Transient Schemes

The first order implicit and explicit Euler schemes will be constructed next by adopting an upwind [14, 17] and a downwind [4, 18] transient interpolation profile, respectively.

13.3.2 First Order Implicit Euler Scheme

The transient first order implicit Euler scheme is obtained by using a first-order “upwind” interpolation profile [14, 17]. As shown in Fig. 13.11, the value of ρϕ at the temporal element face is set equal to the value at the centroid of the upwind element to give

(13.60)

Using Eq. (13.60), Eq.Exercise 14  (13.57) becomes

(13.61)

which is the first order implicit Euler scheme. The scheme is linearized as follows:

(13.62)

Fig. 13.11

First order transient upwind interpolation profile resulting in the implicit first order transient Euler scheme

13.3.2.1 Numerical Diffusion

As this is a first order scheme, it is expected, based on the knowledge gained from convection schemes, to produce numerical diffusion. Its value can be determined by trying to recover the original governing equation using a Taylor series expansion around time t. The value of $$ \left( {\rho \phi } \right)^{{t -\Delta t}} $$ can be expressed as

(13.63)

which can be rearranged into

(13.64)

Substituting Eq. (13.64) into the discretized equation gives

(13.65)

In effect a numerical diffusion term has been added to the equation that scales with the time step in a similar fashion to the upwind scheme for the advection term. So while the scheme is unconditionally stable, the solution it yields is really a stationary solution for large time steps.

13.3.3 First Order Explicit Euler Scheme

The transient first order explicit Euler scheme is obtained by using a first-order “downwind” interpolation profile [4, 18]. As shown in Fig. 13.12, the value of ρϕ at the temporal element face is set equal to the value at the downwind element centroid, yielding

(13.66)

Using Eq. (13.66), Eq.  (13.57) becomes

(13.67)

which is the first order explicit Euler scheme. The scheme is linearized as follows:

(13.68)

Note that now the new time is at $$ t +\Delta t $$ and that the spatial operator of Eq. (13.67) has to be evaluated at time t. Thus, it is possible to evaluate the right hand side completely and find the value of ρϕ at time $$ t +\Delta t $$ without the need to solve a set of linear algebraic equations. This is the explicit scheme and corresponds to the assumption that ρϕ prevails over the entire time step.

Fig. 13.12

First order transient downwind interpolation profile resulting in the explicit first order transient Euler scheme

13.3.3.1 Numerical Anti-Diffusion

Again performing a simple Taylor expansion around time t yields

(13.69)

which can be rewritten as

(13.70)

Substitution into Eq. (13.67) gives

(13.71)

Where now the second order differential term has a negative sign, akin to a negative diffusion or anti-diffusion, with compression effects on profiles, very similar to the Downwind scheme in advection. Again the anti-diffusion term scales with the time step. When used in combination with an upwind convection scheme and a Courant number of 1, it can be shown that the numerical diffusion of the advection scheme and the numerical anti-diffusion of the explicit Euler scheme for a CFL conv equals to 1 are of equal magnitudes and of opposite signs. Thus they cancel each other producing nearly an exact solution. Nonetheless this is not practical as ensuring a CFL conv of 1 on anything but simple one dimensional grids is not an option for real problems.

A related issue to the anti-diffusion behavior is numerical instabilities, which increases with increasing $$ \Delta t $$ placing a very strong restriction on the time step. This can be evaluated by applying the negative neighboring coefficient rule.

13.3.4 Second Order Transient Euler Schemes

Similar to advection schemes, second order transient schemes can be constructed with a linear interpolation profile. The choice could be a symmetric profile (central difference) yielding the Crank-Nicolson (CN) scheme [2], or an upwind one (second order upwind scheme) [4, 19, 20] resulting in the Adams-Moulton scheme [15, 16], an implicit scheme also known as the Second Order Upwind Euler (SOUE).

13.3.5 Crank-Nicholson (Central Difference Profile)

With the ρϕ computed using linear interpolation between the “Upwind” and “Downwind” nodes, the Crank-Nicholson scheme shown in Fig. 13.13 is obtained.

Fig. 13.13

Second order transient central difference interpolation profile resulting in the transient CN scheme

For a uniform time step, this is expressed mathematically as

(13.72)

Substituting in Eq. (13.57), the discretized equation becomes

(13.73)

The linearization coefficients for the CN scheme can be written as

(13.74)

The stencil shown in Fig. 13.9 indicates that the scheme is explicit with the value at level $$ t +\Delta t $$ computed explicitly from the values at times t and $$ t -\Delta t $$. Thus its stability is constrained by a CFL limit.

Again in a similar fashion to the finite difference formulation, it can be reformulated in a two-step procedure using Eqs. (13.48) and (13.49), i.e., a first order implicit Euler step followed by a modified explicit Euler step in the form of extrapolation.

13.3.5.1 Numerical Accuracy

Expanding $$ \left( {\rho \phi } \right) $$ at $$ t +\Delta t $$ and $$ t -\Delta t $$ via Taylor expansions around time t yields

(13.75)

(13.76)

Subtracting Eq. (13.75) from Eq. (13.76), the following equation is obtained:

(13.77)

Substitution into Eq. (13.73) gives

(13.78)

confirming that the scheme is second order accurate. The third order derivative is a dispersive term that results in instability.

13.3.6 Second Order Upwind Euler (SOUE) Scheme

Using the second-order “upwind” interpolation profile depicted in Fig. 13.14, the interface ρϕ values are approximated as

(13.79)

Substituting in Eq. (13.57), the discretized ρϕ field equation is obtained as

(13.80)

which is the implicit second order upwind Euler (SOUE) scheme. In this scheme the values of ρϕ have to be stored for two of the older time steps, with its linearization coefficients given by

(13.81)

Fig. 13.14

Second order upwind Euler scheme

13.3.6.1 Numerical Accuracy

The scheme is second order as can be shown from a Taylor series evaluation. Expanding $$ \left( {\rho \phi } \right)^{{t -\Delta t}} $$ and $$ \left( {\rho \phi } \right)^{{t - 2\Delta t}} $$ around time t give

(13.82)

(13.83)

Multiplying Eq. (13.82) by 4 and subtracting the resulting equation from Eq. (13.83), an expression for the SOUE is obtained as

(13.84)

Combining Eq. (13.84) and Eq. (13.80), the recovered equation for ρϕ becomes

(13.85)

which has a third order numerical dispersion term but no numerical diffusion.

13.3.7 Initial Condition for the FV Approach

The implementation of the finite volume formulation is straight forward except for the initial time step. As shown in Fig. 13.15, the first temporal element is a boundary element in time, as such it does not have an upwind neighbor. Rather the value at the lower element face is used directly at the face resulting in a gradient that is half the correct numerical value. This comes about because it is computed as the difference between the values at $$ \phi_{C}^{{t_{initial} +\Delta t/2}} $$ and $$ \phi_{C}^{{t_{initial} }} $$, which are located half a time step $$ \left( {\Delta t/2} \right) $$ apart, while dividing their difference by a full time step $$ \left( {\Delta t} \right) $$ leading to a non-negligible initial error.

Fig. 13.15

Boundary temporal element

This is easily demonstrated by considering the first temporal element in the discretized equation of the first order implicit Euler scheme. Using Eq. (13.57) the discretized ρϕ field equation is obtained as

(13.86)

For the first temporal element, the upwind interpolation yields a gradient computed as the difference between the ρϕ values at $$ t_{initial} +\Delta t/2 $$ and $$ t_{initial} $$ divided by $$ \Delta t $$. However for the case of a regular element (Fig. 13.16), the gradient is actually between the ρϕ values at $$ t_{initial} + 3\Delta t/2 $$ and $$ t_{initial} +\Delta t/2 $$, divided by $$ \Delta t $$. The difference between the two gradients is substantial, and any scheme that starts with the gradient of Eq. (13.86) will result in a large initial error that will affect the solution at the following steps. This error can be avoided if a grid similar to Fig. 13.16 is adopted. In this case the solution of the finite difference and finite volume methods will be basically similar, as for a regular grid.

Fig. 13.16

Treatment of initial condition and the virtual element of centroid $$ t_{initial} $$

Adopting this approach, the upwind values at the faces of the first temporal element spanning the time interval $$ \left[ {t_{initial} +\Delta t/2,\,t_{initial} + 3\Delta t/2} \right] $$ are obtained as

(13.87)

Substituting in Eq. (13.57), the discretized ρϕ field equation becomes

(13.88)

which is similar to the equation obtained for any internal element.

Example 2

Repeat example 1 using the CN scheme applied via Eq. (13.73) and the SOUE scheme. Use a time step 0.05 to find the values at 0.1, 0.2, and 0.3.

Solution

The analytical solution at times 0.1, 0.2, and 0.3 were found in example 1.

Since two old values are needed, the value at the first time step is found using the first order backward Euler scheme. Thus the numerical solution is obtained using Eqs. (13.61), (13.73), and (13.80), which are reduced to

Based on the suggested implementation note, the first temporal element spans the time interval $$ \left[ {0.025,\,0.075} \right] $$, the second element spans the interval $$ \left[ {0.075,\,0.125} \right] $$, and so on.

Numerical solution using the second order CN scheme

Applying the above equations, the solutions are found as

It is clear that the solution error indicates second order accuracy. The slight differences between the error values obtained here and those reported in example 1 are due to the number of decimal values carried during computations.

Numerical solution using the SOUE scheme

The solution is second order accurate, however it is less accurate than the CN solution.

13.4 Non-Uniform Time Steps

So far a uniform time step was considered. In practical applications it is common to use variable time steps mainly to reduce the computational cost by selecting, at every time step, the maximum allowable time step value that does not violate the CFL condition.

For first order schemes, the discretization is not affected by whether the time step is variable or constant. The situation is different for second order transient schemes since they use a stencil involving two time step values. For the case of the two step implementation of the Crank-Nicolson transient scheme nothing changes except that for each of the two steps a different time step is used. This affects the accuracy as the spatial derivative is no longer at the center of the temporal element. For other second order schemes, the interpolation profile has to be modified to account for the non equal time steps. In what follows a non uniform transient grid is used in the discretization of the transient term for the standard CN [2] and the SOUE [4, 19, 20] schemes. While the finite volume and finite difference methods yield equivalent algebraic relations in a uniform grid, this is not the case for variable time steps as demonstrated in the derivations to follow.

13.4.1 Non-Uniform Time Steps with the Finite Difference Approach

13.4.1.1 Crank-Nicolson Scheme

The CN scheme with non uniform time steps is derived, as shown in Fig. 13.17, by expressing the values of ρϕ at times $$ t +\Delta t $$ and $$ t -\Delta t^{ \circ } $$ in terms of its value and the values of its derivatives at time t using Taylor series as

(13.89)

(13.90)

Then, multiplying Eq. (13.89) by $$ \left( {\Delta t^{ \circ } } \right)^{2} $$ and Eq. (13.90) by $$ \Delta t^{2} $$ and subtracting the resulting equations from each other, an equation for the first derivative is obtained as

(13.91)

Substituting the expression for the gradient from Eq. (13.91) in Eq. (13.3), the discretized equation for the CN scheme with non uniform time steps is given by

(13.92)

Expanding the spatial term, the final form of the algebraic equation becomes

(13.93)

with the time dependent coefficients computed from

(13.94)

For uniform time steps, the coefficients in Eq. (13.39) are recovered.

Fig. 13.17

The finite difference temporal mesh of the CN scheme with non uniform time steps

13.4.2 Adams-Moulton (or SOUE) Scheme

Referring to Fig. 13.18, the Adams-Moulton scheme, also denoted by the SOUE scheme, with non uniform time steps is derived by expressing the values of the dependent variable ϕ at times $$ t -\Delta t $$ and $$ t -\Delta t -\Delta t^{ \circ } $$ in terms of its value and the values of its derivatives at time t using Taylor series as

(13.95)

(13.96)

Multiplying Eq. (13.95) by $$ \left( {\Delta t +\Delta t^{ \circ } } \right)^{2} /\Delta t^{2} $$ and subtracting the resulting equation from Eq. (13.96), a second order representation of the first derivative (i.e., the SOUE scheme) is obtained as

(13.97)

Substituting the expression for the gradient from Eq. (13.97) in Eq. (13.3), the discretized equation becomes

(13.98)

Expanding the spatial term, the final form of the algebraic equation is written as

(13.99)

with the time dependent coefficients obtained from

(13.100)

For uniform time steps the coefficients given in Eq. (13.54) are recovered.

Fig. 13.18

The finite difference temporal mesh of the SOUE scheme with non uniform time steps

13.4.3 Non-Uniform Time Steps with the Finite Volume Approach

Following the terminology used with the FVM, the size of a temporal element is denoted by $$ \Delta t $$, while the distance between the centroids of two consecutive temporal elements is designated by $$ \delta t $$. For uniform time steps both are equal and the time between two consecutive computed fields is $$ \Delta t = \delta t $$ for both the finite difference and finite volume methods. For non-uniform time steps the time remains $$ \Delta t $$ for the finite difference method, however it becomes $$ \delta t = \left( {\Delta t +\Delta t^{ \circ } } \right)/2 $$ for the finite volume method leading to different formulations.

As for the finite difference method, with non-uniform time steps, the current and old time step values affect the scheme interpolation profile and hence its finite volume discretization. This is similar to writing the profile for a convection scheme over a structured non-uniform grid. The procedure used will be illustrated by considering the CN and SOUE schemes. Extension to other profiles is straightforward.

13.4.4 Crank-Nicolson Scheme

The CN scheme is obtained by calculating the value of ρϕ at an interface as the average of the ρϕ values at the main points straddling the interface (Fig. 13.19), i.e.,

(13.101)

Substituting in Eq. (13.57), the discretized ρϕ field equation is obtained as

(13.102)

The linearization coefficients for the CN scheme with non uniform time steps are inferred to be

(13.103)

As in the constant time step case, the method is explicit necessitating storing values of the two previous time steps. Moreover the uniform time steps formulation can be recovered by setting $$ \Delta t =\Delta t^{ \circ } =\Delta t^{ \circ \circ } $$ in Eqs. (13.102) and (13.103).

Fig. 13.19

The finite volume temporal mesh of the CN scheme with non uniform time steps

13.4.5 Adams-Moulton (or SOUE) Scheme

With the second-order “upwind” interpolation profile given by Eq. (11.​84), the interface ρϕ values at the faces $$ t +\Delta t/2 $$ and $$ t -\Delta t/2 $$ displayed in Fig. 13.20 are found to be

(13.104)

Using this profile approximation, the discretized form of Eq. (13.1) over the element C shown in Fig. 13.2 is obtained by substituting Eq. (13.104) in Eq. (13.57) and is given by

(13.105)

The linearization coefficients for the SOUE scheme with non uniform time steps are inferred to be

(13.106)

Similar to the constant time step case, the method is implicit as it requires solving a system of equations to obtain the ϕ field at every time step. The uniform time step form of the equation given by Eq. (13.80) is obtained by setting $$ \Delta t =\Delta t^{ \circ } =\Delta t^{ \circ \circ } $$ in Eq. (13.105).

Fig. 13.20

The finite volume temporal mesh of the SOUE scheme with non uniform time steps

13.5 Computational Pointers

13.5.1 uFVM

The discretization of the transient term in uFVM follows the finite volume method implemented within an implicit framework. The assembly of the transient fluxes resulting from the first order backward Euler scheme is shown in Listing 13.1.

Listing 13.1

Assembly of the transient fluxes resulting from the implicit Euler scheme

13.5.2 OpenFOAM®

In OpenFOAM®, explicit and implicit time derivatives [21] are defined via the namespaces fvm, fvc and the corresponding functions fvc::ddt(rho, phi) and fvm::ddt(rho, phi), respectively. Moreover the first and second order upwind Euler schemes in addition to the second order Crank-Nicholson scheme are available, with the latter implemented following the two-step approach.

The files of the transient schemes are located in the directory “$FOAM_SRC/finiteVolume/finiteVolume/ddtSchemes”. A base class denoted by ddtScheme <Type> is defined from which all time discretization schemes have to be derived.

The first order Euler scheme is implemented in the class EulerDdtScheme. The class is declared on top of the base class ddtScheme <Type>, as shown in Listing 13.2.

Listing 13.2

Decleration of the EulerDdtScheme class

The implementation of the associated fvc and fvm namespaces are defined in the file EulerDdtScheme.C. The implicit evaluation of the Euler scheme is defined via the following function in Listing 13.3:

Listing 13.3

Definition of the function needed for implicit solution using the Euler scheme

As depicted in Listing 13.4, the first step in this function is the definition of the fvMatrix in which only the diagonal coefficient vector is filled.

Listing 13.4

Definition of the fvMatrix

After allocating the needed space for storing the diagonal coefficients and sources, the values to be stored are defined and computed. As shown in Listing 13.5, this is accomplished by first defining the reciprocal of the time step as rDeltaT, then calculating $$ a_{t} = \rho_{C} V_{C} /\Delta t $$ and storing its value in the fvm.diag() vector. The source contribution is computed as the product of $$ a_{t}^{o} = - \rho_{C}^{o} V_{C} /\Delta t $$ and the old value of vf and stored in the fvm.source() vector, where vf is the generic variable used while applying the time scheme.

Listing 13.5

Calculation of the terms added to the diagonal and source vectors

The script in Listing 13.6 shows that OpenFOAM®allows explicit evaluation of the unsteady term using the Euler scheme. In this case, a GeometricField object containing the value of $$ \left( {\rho \phi - \rho^{o} \phi^{o} } \right)/\Delta t $$ is returned (here the value is per unit volume).

Listing 13.6

Explicit calculation of the unsteady term using the Euler scheme

The SOUE scheme is implemented in OpenFOAM® under the class backwardDdtScheme. The definition of the class is on top of the base class, as shown in Listing 13.7.

Listing 13.7

Script used to define the backwardDdtScheme class for the implementation of the SOUE scheme

In this case OpenFOAM® uses information from the current and the previous time steps. In the general case, the time steps are different necessitating the use of two variables to store their values.

The implicit time discretization is defined in a way similar to the first order transient scheme using the function shown in Listing 13.8 through Listing 13.10.

Listing 13.8

Script used to define the implicit discretization using the SOUE scheme

The part of the function displayed in Listing 13.9 calculates the transient coefficients that multiply the current, old, and old-old values of the dependent variable and stores the contribution to the diagonal coefficients in fvm.diag() vector.

Listing 13.9

Script used to calculate the unsteady coefficients and to store the contribution to the diagonal coefficients in the fvm.diag() vector

In the last part of the function shown in Listing 13.10, the contribution of the unsteady term is computed and stored in the fvm.source() vector.

Listing 13.10

Script used to calculate and store contribution to the source in the fvm.source() vector

By comparing the coefficients of the SOUE scheme with the ones given in Eq. (13.100) it is easily seen that OpenFOAM® adopts a finite difference approach for the discretization of the unsteady term whereby the time derivative is approximated via Taylor series expansions.

13.6 Closure

The chapter covered the discretization of the transient term in the unsteady conservation equation. For that purpose, two general methodologies were discussed. One method is based on a finite difference discretization while the other follows a finite volume approach in which the conservation equation is integrated over a temporal element. The first order fully implicit and fully explicit transient schemes were presented. The formulation of higher order approximations was also investigated. This included the CN and the SOUE schemes for uniform and non uniform time steps. The next chapter is devoted to the discretization of the source term, relaxation of the algebraic system of equations, and other related details.

13.7 Exercises

Exercise 1

Transient heat transfer for the one dimensional body shown in Fig. 13.21 is governed by the following energy equation:

The body is insulated at one end while subjected to convective heat transfer at the second end. Other parameters include T R  = 330 K, h R  = 400 W/m²K, k = 55 W/mK, $$ \rho = 7000\,{\text{kg}}/{\text{m}}^{3} $$, and $$ c_{p} = 400\;{\text{J}}/{\text{Kg K}} $$.

Fig. 13.21

One-dimensional domain used for Exercise 1

(a)

Compute the temperature field using the Euler Explicit method for three time steps. Note that the initial temperature is $$ T_{i} = 273\;{\text{K}} $$ with $$ \Delta t = 20\;{\text{s}} $$ and $$ \Delta x = 0.015\;{\text{m}} $$.

(b)

Repeat part a using an implicit Euler scheme.

(c)

Explain the difference in temperatures between the two methods at time t = 60 s.

Exercise 2

The body described in Exercise 1 is now insulated at one end while subjected to a Dirichlet boundary condition at the second end. The initial and boundary conditions are $$ T_{i} = 273\;{\text{K}} $$, $$ T_{b2} = 330\;{\text{K}} $$ while values of other parameters are given by

Compute the temperature field for three time steps using:

(a)

The Adams-Moulton method with uniform time steps $$ \left( {\Delta t = 20\,{\text s}} \right) $$.

(b)

The finite difference form of the Adams-Moulton method with non-uniform time steps ($$ \Delta t_{1} = 10\,{\text s} $$, $$ \Delta t_{2} = 20\,{\text s} $$, and $$ \Delta t_{3} = 30\,{\text s} $$).

(c)

The finite volume form of the Adams-Moulton method with non-uniform time steps ($$ \Delta t_{1} = 10\, {\text s} $$,$$ \Delta t_{2} = 20\,{\text s} $$, and $$ \Delta t_{3} = 30\,{\text s} $$) (Fig. 13.22).

Fig. 13.22

One-dimensional domain used for Exercise 2

Use the implicit Euler scheme for the first time step.

Exercise 3

The body described in Exercise 1 is again subjected to a Dirichlet boundary condition at one end and to a convective heat transfer at the second end. The parameters involved are $$ \Delta x = 0.015\;{\text{m}} $$, $$ T_{i} = 273\;{\text{K}} $$, $$ T_{b1} = 260\;{\text{K}} $$, $$ T_{R} = 330\;{\text{K}} $$, h R  = 400 W/m²K, k = 55 W/mK, $$ \rho = 7000\;{\text{kg/m}}^{3} $$, and $$ c_{p} = 400\;{\text{J}}/{\text{Kg}}\;{\text{K}} $$ (Fig. 13.23).

Fig. 13.23

One-dimensional domain used for Exercise 3

Compute the temperature field for three time steps using:

(a)

The Crank-Nicolson method with uniform time steps $$ \left( {\Delta t = 20\, {\text s}} \right) $$.

(b)

The finite difference form of the Crank-Nicolson method with non-uniform time steps ($$ \Delta t_{1} = 10\, {\text s} $$, $$ \Delta t_{2} = 20\,{\text s} $$, and $$ \Delta t_{3} = 30\,{\text s} $$).

(c)

The finite volume form of the Crank-Nicolson method with non-uniform time steps ($$ \Delta t_{1} = 10\,{\text{s}} $$, $$ \Delta t_{2} = 20\,{\text{s}} $$, and $$ \Delta t_{3} = 30\,{\text{s}} $$).

Use the implicit Euler scheme for the first time step.

Exercise 4

Consider the following equation defined over the one dimensional grid shown in Fig. 13.24:

Fig. 13.24

One dimensional domain used for Exercise 4

(a)

Derive the algebraic equation for element C. Use a first order Euler Explicit scheme for the transient term and linearize the source term given that $$ \beta $$ is positive.

(b)

Is there a step limitation for the equation derived in (a)? If so derive its expression in terms of the appropriate variables.

Exercise 5

Use the implicit backward Euler scheme to integrate in time the linear advection equation given by

and the second order central difference approximation for the spatial derivative.

(a)

Derive the discretized equation.

(b)

Find the accuracy of the scheme

(c)

Determine the stability of the scheme.

Exercise 6

Use the fully implicit Euler scheme in time and the central difference scheme in space to discretize the one dimensional convection diffusion heat equation given by

over a uniform mesh of spacing $$ \Delta x $$ and write it down in the standard form.

There are two issues that should be considered when choosing the time step: stability and accuracy. What are the limits for the time step of the two schemes to achieve stable and accurate solutions? Are these limits similar for both stability and accuracy?

Exercise 7 (OpenFOAM®)

List from Doxygen [22] all derived classes of the ddtScheme <Type> class.

Exercise 8 (OpenFOAM®)

Find in OpenFOAM® the fvm implementation of the first order implicit Euler scheme. Compare the implemented algorithm with Eq. (13.28) and the contribution to the matrix of coefficients with Eq. (13.62).

Exercise 9 (OpenFOAM®)

Compare in OpenFOAM® the fvm implementation of the second order Crank-Nicolson transient scheme with Eqs. (13.43) and (13.44). The C file is located in “$FOAM_SRC/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C”. Hint: In the fvm member function, just check the if statement when mesh().moving() is false.

References

1.

Faires JD, Burden RL (1993) Numerical methods. PWS, Boston, pp 152–153MATH

2.

Crank J, Nicolson P (1947) A practical method for numerical evaluation of solutions of partial differential equations of the heat-conduction type. Proc Cambr Phil Soc 43:50–67MATHMathSciNetCrossRef

3.

Shyy W (1985) A study of finite difference approximations to steady state convection dominated flows. J Comput Phys 57:415–438MATHMathSciNetCrossRef

4.

Moukalled F, Darwish M (2012) Transient schemes for capturing interfaces of free-surface flows. Numer Heat Transf Part B Fundam 61(3):171–203CrossRef

5.

Ascher U, Ruuth S, Spiteri RJ (1997) Implicit-explicit runge-kutta methods for time-dependent partial differential equations. Appl Numer Math 25:151–167MATHMathSciNetCrossRef

6.

Ames WF (1977) Numerical methods for partial differential equations. Academic Press, OrlandoMATH

7.

Milne WE (1953) Numerical solution of differential equations. Wiley, New YorkMATH

8.

Richtmyer RD (1967) Difference methods for initial value problems, 2nd edn. Wiley, New YorkMATH

9.

Birkhoff G, Rota G (1989) Ordinary differential equations. Wiley, New York

10.

Burden R, Faires JD (2010) Numerical analysis, 9th edn. Brooks, Cole

11.

Chapra S, Canale R (2014) Numerical methods for engineers. 7th ed., McGraw Hill, New York

12.

Cheney W, Kincaid D (2013) Numerical mathematics and computing, 7th edn. Brooks/Cole, Boston

13.

Courant R, Friedrichs K, Lewy H (1928) Über die partiellen Differenzengleichungen der mathematischen Physik. Math Ann (in German) 100:32–74MATHMathSciNetCrossRef

14.

Patankar SV (1980) Numerical heat transfer and fluid flow, Hemisphere, New York

15.

Peinado J, Ibáñez J, E. Arias E, V. Hernández V (2010) Adams–Bashforth and Adams–Moulton methods for solving differential Riccati equations. Comput Math With Appl 60(11):3032–3045

16.

Ferziger JH, Peric M (2013) Computational methods for fluid dynamics, 3rd edn. Springer, Germany

17.

Courant R, Isaacson E, Rees M (1952) On the solution of nonlinear hyperbolic differential equations by finite differences. Commun Pure Appl Math 5:243–255MATHMathSciNetCrossRef

18.

Darwish M, Moukalled F (2006) Convective schemes for capturing interfaces of free-surface flows on unstructured grids. Numer Heat Transf Part B Fundam 49(1):19–42CrossRef

19.

Darwish M, Moukalled F (1994) Normalized variable and space formulation methodology for high-resolution schemes. Numer Heat Transf Part B Fundam 26(1):79–96CrossRef

20.

Leonard BP (1981) A survey of finite differences with unwinding for numerical modeling of the incompressible convection diffusion equation. In Taylor C, Morgan K (eds.) Computational techniques in transient and turbulent flow, Pineridge Press, Swansea, UK, 2:1–35

21.

OpenFOAM, 2015 Version 2.3.x. http://​www.​openfoam.​org

22.

OpenFOAM Doxygen, 2015 Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_14

14. Discretization of the Source Term, Relaxation, and Other Details

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter is devoted to a number of “small” numerical details that may have “big” effects on the solution behavior. First the treatment of the source term in the general case when it is solution dependent (i.e., when $$ Q^{{\phi}} = Q^{{\phi}} \left({\phi}\right) $$) is examined. The source is linearized in terms of the dependent variable and split into two parts, one treated explicitly and the second treated implicitly. This is followed by a discussion of explicit and implicit techniques for under-relaxing the algebraic equations. Several implicit under-relaxing approaches are presented, starting with the well known implicit under relaxation method of Patankar (Numerical heat transfer and fluid flow, 1980) [1], the E-factor method of van Doormaal and Raithby (Numerical Heat Transfer 7:147–163, 1984) [2], and the false transient approach of Mallinson and de Vahl Davis (Journal of Computational Physics 12(4):435–461, 1973) [3]. Then the residual form of the discretized algebraic equation is introduced. The chapter ends with the presentation of convergence indicators used to evaluate the solution convergence status.

14.1 Source Term Discretization

Source terms (sink and source) appear in the governing equations of many flow and transport phenomena problems. Examples include the equations of turbulence models, chemical reactions, radiation heat transfer, mass transfer, and multiphase flows, to cite a few. These source terms affect not only the physics of the problem, but also the numerical stability of computations. However, if properly handled, source terms may yield improvement in robustness. A general recommendation is to treat negative values (sinks) implicitly, while positive values (sources) should be evaluated explicitly.

The treatment of source terms can be clarified by considering the discretized form of the general conservation equation for the variable $$ \phi $$ over the element of centroid C and volume $$ V_{C} $$ with a source explicitly displayed (Fig. 14.1). This equation is given by

(14.1)

where $$ Q_{C}^{\phi } V_{C} $$ represents the source term integrated over the element C.

Fig. 14.1

An element C with a source term $$ Q^{\phi } $$

In general the source term is a function of the dependent variable $$ \phi $$ with its functional relationship expressed as

(14.2)

In this form the source can be explicitly calculated based on the available $$ \phi $$ values, which in an iterative process represent values from the previous iteration. Whereas this approach is acceptable if the value of $$ Q_{C}^{\phi } $$ is constant or relatively small, when the variation in $$ Q_{C}^{\phi } $$ is large in comparison with other terms in the equation the rate of convergence can be negatively affected. In such situations, the rate of convergence may be improved by linearizing $$ Q_{C}^{\phi } $$ using a Taylor-like series expansion. Denoting values at the previous iteration with a superscript $$ ^{*} $$, the value of the source term $$ Q_{C}^{\phi } $$ at the current iteration can be expressed as

(14.3)

In a control volume context, the right hand side of Eq. (14.1) can be written as

(14.4)

Substituting back in Eq. (14.1), the algebraic equation becomes

(14.5)

In this formulation the implicit part of the source, $$ FluxC_{C} $$ [defined in Eq. (14.3)], is required to be negative to guarantee diagonal dominance or else the Scarborough criterion may not be fulfilled causing divergence. In addition, for the case when the variable $$ \phi $$ is positive-definite, the explicit part, $$ FluxV_{C} $$ [Eq. (14.3)], must be positive to ensure positive $$ \phi $$ predictions.

Example 1

In problems involving heat transfer by radiation, the source term in the energy equation takes the form

where A is a constant, T is the temperature at any grid point, and $$ T_{\infty } $$ represents the non-varying ambient temperature. Integrate this source term over an element of centroid C and volume $$ V_{C} $$ , then linearize it using different alternatives and explain their consequences on convergence.

Solution

Several arbitrary choices can be selected to linearize $$ Q^{T} $$. Option 1

Adopting this alternative may cause the solution to diverge as it results in negative values for $$ FluxV_{C} $$, whenever $$ T_{C} > T_{\infty } $$, leading to possible unphysical negative absolute temperature values during the iterative process. Option 2 Linearizing with respect to the value of temperature of the previous iteration $$ T_{C}^{*} $$, the expanded form of the source term is obtained as

Comparing with Eq. (14.9), $$ FluxC_{C} $$ and $$ FluxV_{C} $$ are found to be

This is the ideal approach resulting in a positive $$ FluxV_{C} $$ and a negative $$ FluxC_{C} $$ and giving the best rate of convergence as the introduced implicitness in the solution is the optimum one.

14.2 Under-Relaxation of the Algebraic Equations

As described in previous chapters, the end product of the discretization process is a set of algebraic equations of the form given by Eq. (14.1), in which $$ a_{F} $$ refers to a neighboring coefficient (Fig. 14.2) representing the effect of the neighboring variable $$ \phi_{F} $$ on the cell variable $$ \phi_{C} $$, $$ b_{C} $$ is the right hand side of the equation that usually includes the source terms and the effects of other variables, while $$ a_{C} $$ is the main coefficient of the algebraic equation and contains the effects of various influences, including the spatial discretization effects, the transient effects, etc. The set of equations represented by Eq. (14.1) is usually diagonally dominant.

Fig. 14.2

Matrix representation of Eq. (14.1)

In the iterative solution of the system of algebraic equations it is often desirable to slow down the changes in the values of the dependent variable from iteration to iteration. This is needed to improve the convergence of non-linear problems but also to avoid divergence when starting with a guessed initial field that could be far from the solution. The non-linearities can arise because of the non-orthogonality of the grid system, the presence of source terms, the non-linear nature of the modeled equations, etc. One method commonly used to promote convergence by “slowing down” (“relaxing”) the (sometimes excessive) changes made to the values of the variable during solution is the relaxation method. The standard relaxation method used in many CFD codes is the implicit under relaxation method of Patankar [1], which was briefly presented in Chap. 8. Other under-relaxation methods have been presented in the literature such as the E-Factor [2] relaxation method and the False transient method [3]. Van Doormaal and Raithby [2] have shown that these different relaxation methods are somewhat related and that the under-relaxation in any of the methods can be related to the under-relaxation in the other methods, as they all basically retard the effect of neighboring elements and sources on the under-relaxed element value. In other words, under-relaxation affects equally the source term in the concerned element and its spatial coefficients. Some of these relaxation methods are presented next.

14.2.1 Under-Relaxation Methods

Solution relaxation may be performed either explicitly after the solution at any iteration is obtained or implicitly by incorporating its effect into the equation before the solution is obtained. Both methods are outlined below.

14.2.2 Explicit Under-Relaxation

In the explicit under-relaxation method, at the end of every iteration after a new solution is obtained, all cells in the computational domain are visited and the predicted value $$ \left( {\phi_{C}^{new,\,predicted} } \right) $$ in any cell C is modified according to

(14.6)

where $$ \lambda^{\phi } $$ is the relaxation factor, which for both explicit and implicit relaxation can be interpreted according to its assigned value as follows:

1.

A value of $$ \lambda^{\phi } < 1 $$ results in under-relaxation. This may slow down the speed of convergence but increases the stability of the calculation, i.e., it decreases the possibility of divergence or oscillations in the solution.

2.

A value of $$ \lambda^{\phi } = 1 $$ corresponds to no relaxation. If applied, then the predicted values during an iteration are the ones used at the next iteration.

3.

A value of $$ \lambda^{\phi } > 1 $$ leads to over-relaxation. It can sometimes be used to accelerate convergence but usually decreases the stability of the calculations.

Explicit under-relaxation is used to under-relax pressure in the SIMPLE algorithm, which will be introduced in the next chapter. Further, in problems where the fluid properties depend on the solution and are iteratively updated, explicit under-relaxation may be necessary to promote convergence. Examples include, but are not limited to, the turbulent viscosity in turbulent flows, the density in compressible flows, and computed interface values using HR schemes. In addition, it may be used to under-relax individual terms in the conservation equation such as the source term, and in some cases gradients of solution variables.

14.2.3 Implicit Under-Relaxation Methods

Several approaches in this category have been developed. The standard method that was presented in Chap. 8 is Patankar’s approach [1], a summary of which is given here for completeness. Other methods include the E-factor approach and the false transient technique, which are also discussed.

14.2.3.1 Patankar’s Under-Relaxation

As mentioned above, the iterative solution of a system of equations can be under-relaxed by introducing a relaxation factor $$ \lambda^{\phi } $$ and expressed via Eq. (14.6). To simplify the notation used with implicit under-relaxation, Eq. (14.6) is modified to

(14.7)

where $$ \phi_{C}^{*} $$ is the value of $$ \phi_{C} $$ from the previous iteration. In Patankar’s relaxation approach, $$ \phi_{C}^{new\,iteration} $$ in Eq. (14.7) is replaced by its equivalent expression from Eq. (14.1) to yield

(14.8)

re-arranging, the equation becomes

(14.9)

In Eq. (14.9) the relaxation factor $$ \lambda^{\phi } $$ modifies the diagonal coefficient and the right hand side without modifying the equation mathematically. Since $$ \lambda^{\phi } < 1 $$, under relaxation increases the diagonal dominance of the algebraic system and enhances the stability of the iterative linear solver. This is an important advantage when compared to the explicit approach.

However it is worth noting that the implicit relaxation applies a relation that is proportional to the diagonal coefficient. Thus the relaxation will be larger for a larger diagonal coefficient, which translates into a larger relaxation of higher importance for smaller control volumes. This is demonstrated in the next section.

14.2.3.2 E-Factor Relaxation

The E-Factor method [2] is a reformulation of Patankar’s method. It is derived by rewriting Eq. (14.1) in the following form:

(14.10)

under-relaxing, the right hand side of Eq. (14.10) is transformed to

(14.11)

Replacing the under-relaxation factor with $$ \frac{{E^{\phi } }}{{1 + E^{\phi } }} $$, Eq. (14.11) becomes

(14.12)

which can be reformulated as

(14.13)

With this formulation the under-relaxation effect can be readily interpreted in term of some artificial transient time scale that advances $$ \phi_{C} $$ at each solver iteration. The time step $$ \Delta t $$ can be shown to be proportional to the characteristic time interval $$ \Delta t^{*} $$ according to

(14.14)

where

(14.15)

In Eq. (14.15) $$ \rho_{C} $$ is the density of the fluid in cell C of volume $$ V_{C} $$. The characteristic time interval is related to the time required to diffuse and convect a change of $$ \phi_{C} $$ across the element. Thus the E-factor is equivalent to an element CFL number.

It is clear from Eq. (14.15) that the time step advancement of the E-Factor relaxation is dependent on the cell volume, with the solution in a smaller element advancing more slowly than in a coarser element. This can be detrimental to the convergence rate for a steady state solution since it is very common to use highly stretched elements with small volumes near boundaries, thus forcing a critical region in the computational domain to advance at a very small time step compared to the remainder of the domain. This is also a characteristic of the Patankar relaxation method.

The relation between $$ E^{\phi } $$ and $$ \lambda^{\phi } $$ can be shown to be

(14.16)

In general values of $$ E^{\phi } $$ are chosen in the range of 4–10, corresponding to values between 0.75 and 0.9 for $$ \lambda^{\phi } $$.

Example 2

In the figure below an illustrative boundary mesh is shown. Elements A and D represent stretched elements near a wall boundary, with the volume ratio of about $$ V_{{C_{A} }} /V_{{C_{D} }} \approx 0.1 $$ . The value of the diagonal coefficients for such meshes are usually dominated by the diffusion coefficient and in this case would be around $$ a_{{C_{A} }} /a_{{C_{D} }} \approx 2 $$ since element A has a boundary face.

Compute the relative pseudo transient time for elements A and D if an under-relaxation factor of 0.8 is applied (Fig. 14.3).

Fig. 14.3

Schematic of a boundary mesh with stretched elements

Solution

Solution starts by computing the equivalent E factor for the applied relaxation factor

thus the pseudo time step for each of the elements is

Therefore the relative pseudo time steps for elements A and D can be computed as

implying that the pseudo time step for element D is nearly 20 times that of element A.

14.2.3.3 False Transient Relaxation

The false transient relaxation method [3] is a modification of the Euler first order implicit transient method, wherein the previous iteration values are used instead of the old time step values. As in the Euler method the diagonal dominance of the algebraic equation is increased through the addition of the pseudo-transient term, $$ a_{C}^{o} \phi_{C} $$, to the diagonal coefficient and the pseudo old time step term, $$ a_{C}^{o} \phi_{C}^{*} $$, to the right hand side. With these modifications the equation becomes

(14.17)

where the coefficient $$ a_{C}^{o} $$ is computed as

(14.18)

and is basically equal to the transient coefficient obtained from the first order implicit Euler discretization of the transient term, $$ \rho_{C} $$ is the density, $$ V_{C} $$ the element volume, and $$ \Delta t $$ a user-defined false time step. For large values of $$ \Delta t $$, the added term is negligible, and under-relaxation effects are negligible. Therefore the solution of the equation is the same as the original unrelaxed one. For very small values of $$ \Delta t $$, the value of $$ a_{C}^{o} $$ becomes large dominating other terms. The solution is heavily under-relaxed leading to minute change in the value of $$ \phi_{C} $$ (i.e., $$ \phi_{C} \approx \phi_{C}^{*} $$).

In addition to allowing the solution to advance consistently over the entire computational domain, the false transient method ensures the addition of a non-zero contribution to the diagonal coefficient even in extreme cases when the diagonal coefficient is zero.

There is no general rule for assigning optimum under-relaxation factors as values used in one case may not work properly for another case. In addition, different equations may be assigned different under-relaxation factors. Further, it is not necessary to use the same under-relaxation value throughout the computational domain. Furthermore, under-relaxation values may vary from iteration to iteration. For the SIMPLE algorithm to be described in Chaps. 15 and 16, Raithby and Schneider [4] derived an optimum relation between the under-relaxation factors for the velocity and pressure fields, which will be presented in the next chapter.

14.3 Residual Form of the Equation

The discretized algebraic equation has been written so far in its “direct” or “standard” form as

(14.19)

which is the form used in OpenFOAM®.

Equation (14.19) can also be written in “correction” or “residual” form by rearranging its terms so as to solve for the correction needed to satisfy the equation. Thus if $$ \phi_{C}^{*} $$ and $$ \phi^{\prime}_{C} $$ are the previous iteration value of $$ \phi_{C} $$ and the correction needed to satisfy Eq. (14.19), respectively, then the solution is given by

(14.20)

and Eq. (14.19) can be rewritten as

(14.21)

or

(14.22)

Note that the right hand side of Eq. (14.22) represents the residual error of the equation for the field $$ \phi_{C}^{*} $$. Denoting this residual over element C by $$ Res_{C}^{\phi } $$, Eq. (14.22) becomes

(14.23)

It is worth noting that for the exact field $$ Res_{C}^{\phi } $$ would be zero.

While mathematically equivalent to Eq. (14.19), Eq. (14.23) has one numerical advantage. In this form, numerical errors during the solution of the equation are slightly less than those associated with the standard form for cases when small variations are expected for large values of $$ \phi $$.

14.3.1 Residual Form of Patankar’s Under-Relaxation

The residual form of the implicit Patankar relaxation equation is derived by rewriting Eq. (14.19) in the following form:

(14.24)

which can be simplified to

(14.25)

Noticing that the right hand side of the above equation represents the residual of the original equation, Eq. (14.25) can be written as

(14.26)

implying that under-relaxing the equation in residual form necessitates modifying only the diagonal coefficient.

14.4 Residuals and Solution Convergence

In any iterative solution process it is important to be able to determine when the solution can be considered good enough, or when the error can be estimated to be below a certain tolerance, or even to what precision the conservation equations have been satisfied. Having the tools to answer any of the above questions is an important ingredient for any CFD code. This can be rephrased as how to evaluate the degree of convergence of the solution field without knowing the final solution. To this end a number of indicators were proposed over the years, from the simple monitoring of a point at a location over a number of iterations, to the monitoring of an integrated value such as the drag coefficient, the total mass flow, the wall shear stress, and so on, or more commonly the monitoring of some type of equation residual. The challenge being that the method has to be used for a wide range of flow parameters and for a variety of geometries and boundary conditions.

14.4.1 Residuals

As a solution to the discretized system of equations represented by Eq. (14.1) is sought, the error in the balance equation is quantified by defining the element residual error as

(14.27)

It is clear that when the solution is reached and the equation satisfied, the value of $$ Res_{C}^{\phi } $$ will be zero. Using $$ Res_{C}^{\phi } $$ a number of residual indicators for the whole domain can be derived as detailed next.

14.4.2 Absolute Residual

As defined by Eq. (14.27), the residual may be a positive or a negative quantity. Since the sign is immaterial, the absolute value of the $$ Res_{C}^{\phi } $$, denoted by $$ R_{C}^{\phi } $$, is used to decide whether a solution has converged or not. If $$ R_{C}^{\phi } $$ decreases with iterations then the solution will be converging otherwise it will be diverging. The value of $$ R_{C}^{\phi } $$ at point C is defined as

(14.28)

14.4.3 Maximum Residual

The solution is assumed to have converged when the maximum value of the absolute residuals, defined as,

(14.29)

over the domain drops below a vanishing quantity $$ \varepsilon $$, i.e.,

(14.30)

14.4.4 Root-Mean Square Residual

Another parameter used as a convergence indicator, is the average of the square root of the sum of the squares of the absolute residuals $$ R_{C,rms}^{\phi } $$, mathematically given by

(14.31)

In this case the convergence criteria is written as

(14.32)

14.4.5 Normalization of the Residual

The level of the absolute residual is a strong function of the variable $$ \phi $$. Therefore different variables result in different levels of $$ R_{C}^{\phi } $$. This makes it difficult to discern whether a solution has converged or not. In such cases a better insight can be gained through scaling the different residuals by dividing them by their respective maximum fluxes. Recalling that $$ a_{C} $$ represents the sum of the fluxes over the element, the residuals are scaled relative to the local value of the property $$ \phi $$ to obtain a relative error by dividing them by the maximum value of $$ a_{C} \phi_{C} $$ over the domain such that

(14.33)

The solution is assumed to have converged when the maximum value of the scaled absolute residuals has dropped below a vanishing quantity $$ \varepsilon $$, i.e.,

(14.34)

It is common to require $$ \varepsilon $$ for scaled residuals to be of the order of $$ 10^{ - 3} $$ to $$ 10^{ - 5} $$ or less for convergence.

In addition to using either the absolute or scaled residuals, it is always insightful to monitor integrated quantities, as mentioned above, before concluding that the solution has converged. Always ensure proper convergence before declaring that a solution has converged as non-converged solutions can be misleading.

14.5 Computational Pointers

In this section, the source term linearization and relaxation techniques used in uFVM and OpenFOAM® are discussed.

14.5.1 uFVM

14.5.1.1 Source Term Linearization

The linearization and assembly of the source term in uFVM is implemented in the function cfdAssembleSourceTerm displayed in Listing 14.1. The function relies on the linearization set by the user, which has to supply the constant part of the source, Sb, and the linearized part, Sc. These terms are then added to FLUXV and FLUXC, as in Eq. (14.4).

Listing 14.1

Linearization and implementation of the source term

It is worth noting that in uFVM the equations are solved in residual form, which explains the implementation of the total source in FLUXTE, rather than its constant part only.

14.5.1.2 Under-Relaxation

The implicit under-relaxation method of Patankar is implemented in ufvm. Since the equations are solved in residual form, their under-relaxation (Listing 14.2) requires modifying their diagonal coefficients only, as demonstrated by Eq. (14.26).

Listing 14.2

Implementation of Patankar’s implicit under-relaxation method

14.5.2 OpenFOAM®

14.5.2.1 Source Term Linearization

In Sect. 14.1, the treatment of the source in the transport equation of a generic variable $$ \phi $$ was discussed. The suggested linearization (or implicit treatment) can be viewed as imposing an artificial time step onto the matrix of coefficients, thus affecting the characteristic time of advancing the solution. In addition it increases diagonal dominance and enhances the solution robustness of the algebraic system of equations by allowing for an inherent relaxation to come into action when needed. That is, whenever the negative source term changes substantially, the system self-adapt the time step resolution in order to capture the characteristics of the modeled phenomenon. This is in contrast with the non-linearization approach (explicit treatment), which necessitates heavier under-relaxation of the system of equations with the relaxation factor being generally not optimal.

For the discretization of the source term OpenFOAM® [5] uses the implicit fvm:: and explicit fvc: : operators. Specifically the implementation of the fvc:: operator can be found in the directory “$FOAM_SRC/finiteVolume/finiteVolume/fvc/” in the corresponding files fvcSup.H and fvcSup.C. However it is usually the norm to define the explicit source term into the equation without the need for using the fvc:: operator. For example considering the case of a generic scalar transport equation with a source term that does not depend directly on the main variable and thus cannot be linearized, given by

(14.35)

In OpenFOAM® Eq. (14.35) can be implemented, as shown in Listing 14.3,

Listing 14.3

Defining an explicit source term without invoking the fvc operator

with the source term not requiring any special wrapping function or operator.

The implementation of the fvm:: functions can be found in the directory “$FOAM_SRC/finiteVolume/finiteVolume/fvm/” in the corresponding files fvmSup.H and fvmSup.C. The discretization of the linearized source is set in function fvm::Sp. As per Eq. (14.5), the implicit part of the source term is added as a contribution to the main diagonal of the coefficient matrix. For that purpose the function Sp is defined in Listing 14.4.

Listing 14.4

Script used for the definition and implementation of the Sp function

It is worth mentioning that the function Sp treats the source term irrespective of the sign of the slope of its linearized form. This means that for the case when the slope of the linearized term is positive the operation may lead to divergence of the solution algorithm as it destroys the diagonal dominance of the set of algebraic equations. Thus it is always important to ensure that the implicit treatment is used only when it results in a negative slope of the linearized term. For the case when the slope of the linearized source term can assume, in different regions of the domain, different values (positive and negative), the negative contributions should be treated as implicit and positive contribution as explicit. For that purpose OpenFOAM® provides a special source term function denoted by fvm::SuSp in which the implicit/explicit treatment is automatically performed. The script of this function is given in Listing 14.5.

Listing 14.5

Script used for the definition and implementation of the SuSp function

In this function both diagonal and source term vectors are filled depending on the local sign of the slope of the linearized source term. In fact the use of the max/min function achieves the selective discretization. For instance, if in a generic cell of the domain the slope of the linearized source term assumes a negative value (here taken as positive) the contribution to the source vector is zero (i.e., min(SuSp.field(), scalar(0)) = 0) and the opposite for the diagonal contribution.

14.5.2.2 Under-Relaxation

The under-relaxation methods used in OpenFOAM® include both the implicit technique of Patankar and the explicit variable relaxation. More specifically the implicit under relaxation is applied only to the fvMatrix object (i.e., the actual finite volume discretization matrix) while the explicit relaxation is defined only for GeometricField objects.

The explicit relaxation described by Eq. (14.6) can be found in the file GeometricField.C in the “$FOAM_SRC/OpenFOAM/fields/GeometricFields/GeometricField” directory. The dedicated function (Listing 14.6) inside the GeometricField class for performing this task is given by

Listing 14.6

Script of the function in the GeometricField class for explicit under relaxation

where the operator “==” defines the new value of the GeometricField itself based on the current value and the previous one in accordance with Eq. (14.6).

In general to explicitly relax a variable, first its value is stored in the prevIter() array, after that calculations are performed to obtain the new predicted value, and finally relaxation is applied. For example, using the pressure “p” as the GeometricField variable the following should be written (Listing 14.7):

Listing 14.7

Explicit under relaxation of the pressure field

In this case the value of the relaxation factor is directly read from the fvSolution dictionary. In case the developer requires a certain constant value, say 0.5, the last line in Listing 14.5 should be replaced by “ p.relax(0.5); ”.

The Patankar relaxation is applied directly to the matrix of coefficients and in OpenFOAM® it is implemented inside the fvMatrix class. The file fvMatrix.C in the directory “$FOAM_SRC/finiteVolume/fvMatrices/fvMatrix” contains the definition of the implicit relaxation given in Listing 14.8.

Listing 14.8

Script for the definition of implicit relaxation

The function definition is quite long, mainly due to the constraints imposed by the diagonal dominance requirement of the matrix of coefficients, but the relevant code reads (Listing 14.9)

Listing 14.9

Excerpts of the script used for implicit under relaxation

In the first part, after checking the sign of the slope of the linearized source, references to the diagonal and source vectors are setup. The original diagonal is stored under the “D0” scalar field and then divided by the relaxation factor “alpha”. An additional contribution is added to the source vector of the matrix where “psi_” is the variable associated with the fvMatrix class. The source term looks slightly different from the right hand side of Eq. (14.4) but defines exactly the same contribution, as shown in the following equation:

(14.36)

14.6 Closure

The chapter dealt with the treatment of the source term in the general conservation equation and discussed several methods used for under-relaxing the algebraic system of equations. The chapter also discussed some of the indicators used for checking convergence. The next chapter is devote for the solution of incompressible flow problems.

14.7 Exercises

Exercise 1

Linearize the following source term where the dependent variable is $$ \phi $$:

Exercise 2

Consider the following equation:

Derive the algebraic equation for an element C. Use a first order Euler scheme for the transient term and linearize the source terms given that $$ \beta $$ and $$ \kappa $$ are both positive.

Exercise 3

Consider the steady convection diffusion equation given by

a.

Discretize the above equation using the SMART scheme with a deferred correction approach for the convection term, and linearize the source term.

b.

Then apply under-relaxation to the discretized equation using

(i)

Patankar’s under-relaxation method

(ii)

The E-Factor relaxation method

(iii)

The false transient method

Exercise 4

In the solution of turbulent flows (which will be the subject of Chap. 17), turbulence models are introduced. One such models is the well-known two-equation $$ k - \varepsilon $$ turbulence model, with k and $$ \varepsilon $$ governed by conservation equations that have the form of the general conservation equation. The $$ \varepsilon $$ equation in the model has the following source term:

where $$ \rho $$ is the fluid density, $$ C_{\varepsilon 1} $$ and $$ C_{\varepsilon 2} $$ are positive constants, and $$ P_{k} $$, k, and $$ \varepsilon $$ are all positive quantities. Suggest a linearization for $$ Q_{C}^{\varepsilon } $$.

Exercise 5

In solving the momentum equation in $$ r\theta Z $$ coordinates, the momentum equation in the $$ \theta $$ direction has the following source term:

Suggest a linearization for $$ Q_{C}^{v_{\theta}} $$.

Exercise 6

The Fithigh-Nagumo equations, presented below, model the evolution of animal coat pattern formation. The equations represent concentrations of two chemical substances influencing skin pigmentation whose reaction-diffusion interaction result in the formation of patterns that are reminiscent of the zebra or jaguars skins. The variations in the resulting patterns depend on the constants used in the model. The model equations are given by

Solve these equations using uFVM and OpenFOAM® for the following values of the constants:

Let the computational domain be a square of dimension [4, 4] discretized with a mesh of size $$ 100 \times 100 $$ elements. As boundary conditions, use a zero gradient over all boundaries with a random initial conditions for the $$ \phi $$ (values within [0, 1]) and initial conditions for $$ \varphi = 1 - \phi $$. Solve the problem over 5 s with a time step $$ \Delta t\,\le\,10^{ - 4} $$ s, using the first order Euler Implicit Scheme and the second order Crank-Nicholson scheme and compare results. Make sure that the source term is linearized.

References

1.

Patankar S (1980) Numerical heat transfer and fluid flow. McGraw Hill, New YorkMATH

2.

Van Doormaal JP, Raithby GD (1984) Enhancement to the SIMPLE method for predicting incompressible fluid flows. Numer Heat Transf 7:147–163MATH

3.

Mallinson GD, de Vahl Davis G (1973) The method of the false transient for the solution of coupled elliptic equations. J Comput Phys 12(4):435–461MATHCrossRef

4.

Raithby GD, Schneider GE (1979) Numerical solution of problems in incompressible fluid flow: treatment of the velocity-pressure coupling. Numer Heat Transf 2:417–440CrossRef

5.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

Part III
Algorithms

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_15

15. Fluid Flow Computation: Incompressible Flows

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

In previous chapters the procedure for discretizing and solving the general transport equation for the variable $$ \phi $$ in the presence of a known velocity field was formulated. In general, the velocity field is not known and has to be computed by solving the set of Navier-Stokes equations. For incompressible flows this task is complicated by the strong coupling that exist between pressure and velocity and by the fact that pressure does not appear as a primary variable in either the momentum or continuity equations. The focus of this chapter is on presenting a method that addresses these two issues, and computes the flow field for incompressible fluid flows. This is accomplished initially on a one dimensional staggered grid, then on a collocated one dimensional grid and finally on a collocated three dimensional unstructured grid. In addition to fully deriving the SIMPLE, SIMPLEC, PRIME and PISO algorithms, the Rhie-Chow interpolation and its extension to transient, relaxation and body force terms are clearly formulated. Finally, the implementation details for a number of frequently encountered boundary conditions are presented.

15.1 The Main Difficulty

The general conservation equation dealt with in previous chapters can be reformed into an equation similar to the continuity and momentum equations. Yet the numerical techniques presented up till now are not enough to allow for the resolution of the Navier-Stokes equations. Solving general fluid flows requires an algorithm [1] that can deal with the pressure velocity coupling. To understand this issue, the continuity and momentum equations are reproduced below.

(15.1)

(15.2)

That Eqs. (15.1) and (15.2) are nonlinear is not by itself an unsurmountable difficulty, since such a problem is usually handled by adopting an iterative approach. Moreover, Eq. (15.2) is a vector equation, which when written in terms of its components results in a system of scalar equations that can be solved sequentially. Furthermore, the stress tensor can be reformulated into a diffusion-like term and treated implicitly, with its second part (i.e., the transpose of the velocity gradient) evaluated explicitly based on previous iteration values and added to the source. The main issue that cannot be addressed directly with the numerics of the general scalar equation, is the unavailability of an explicit equation for computing the pressure field that appears in the momentum equation.

A review of Eqs. (15.1) and (15.2) reveals that while the velocity field can be computed using the momentum equation, the pressure field appearing in the momentum equation cannot be computed directly from the continuity equation. This strong yet implicit coupling can be made more evident by rewriting the set of equations in a matrix form as

(15.3)

In this form, Eq. (15.3) shows a zero diagonal block in the system, which is a characteristic of saddle point problems, indicating that it cannot sustain the solution of the pressure and velocity fields by any iterative mean. Consequently, an equation for pressure is required and should be derived.

One approach is to simply reformulate the system of momentum and continuity equations by decomposing matrix A into a lower (L) and an upper (U) triangular matrices as

(15.4)

where the term −BF ⁻¹ B T is the Schur complement matrix.

This is in essence the approach that needs to be followed in order to iteratively solve the Navier-Stokes equations. This technique is embodied in the classical segregated SIMPLE (Semi Implicit Method for Pressure Linked Equations) algorithm of Patankar and Spalding [1–3].

The solution procedure is based on reformulating the Navier-Stokes equations in terms of a momentum and a pressure equation, which are then discretized and solved sequentially. The pressure equation is constructed by combining the semi-discretized momentum and continuity equations (approximation of the Schur complement matrix).

The algorithm is driven by a Picard type iterative procedure during which the momentum equation is solved using the pressure field of the previous iteration. The resulting velocity field conserves momentum but not necessarily mass. This velocity field is then used to construct the pressure equation whose solution is used to correct both the pressure and velocity fields so as to enforce mass conservation. A new iteration is then started and the sequence is repeated until the velocity and pressure fields satisfy both mass and momentum conservation.

This algorithm can be described in matrix form as

(15.5)

followed by an update to the velocity field using

(15.6)

where in Eqs. (15.5) and (15.6) F ⁻¹ is approximated by its inverse diagonal, D ⁻¹, and the superscript (*) refers to intermediate values at the current iteration. The steps required are summarized as follows:

Solve: Fv * = f b

Solve: −BD ⁻¹ B T p * = −Bv *

Update: v = v * − D −1 B T p *

Update: p = p *

This kind of splitting is similar to that used in the SIMPLE family of algorithms, which is the subject of this chapter.

15.2 A Preliminary Derivation

The difficulties faced in developing a solution algorithm for incompressible flow problems will be highlighted by performing the discretization in a one dimensional space over the uniform grid displayed in Fig. 15.1. For simplicity, the flow is assumed to be steady. The simplified continuity and momentum equations (written in conservative form) are given by

Fig. 15.1

One dimensional domain

(15.7)

(15.8)

15.2.1 Discretization of the Momentum Equation

The discretization of the momentum equation starts by integrating Eq. (15.8) over element C shown in Fig. 15.1 to yield

(15.9)

The volume integrals of the convection and diffusion terms in Eq. (15.9) are then transformed into surface integrals by invoking the divergence theorem to give

(15.10)

Representing the surface integrals by summation of fluxes over the faces of the element, and using a single Gaussian point for the face integrals, the semi-discretized forms of the left and right hand sides of Eq. (15.8) become

(15.11)

which can be rewritten as

(15.12)

The convection and diffusion terms can be discretized using any of the techniques described in previous chapters to yield an algebraic equation of the form

(15.13)

The discretization of the pressure term is deferred till after the discretization of the continuity equation.

15.2.2 Discretization of the Continuity Equation

The discretized form of the continuity equation is obtained by integrating Eq. (15.7) over element C displayed in Fig. 15.1 to give

(15.14)

Again making use of the divergence theorem to transform the volume integral into a surface integral and then into summation of fluxes over the faces of the element, the discrete form of the continuity equation is obtained as

(15.15)

or

(15.16)

15.2.3 The Checkerboard Problem

The discretization of the pressure term may be accomplished by adopting either of the following two approaches. In the first approach, the volume integral is computed via a single Gaussian integration point resulting in

(15.17)

Using a central difference scheme, the discretized form of Eq. (15.17) is obtained as

(15.18)

In the second approach, the volume integral of the pressure gradient term is transformed into a surface integral such that

(15.19)

Rewriting the surface integral as a summation of fluxes over the faces of the element, Eq. (15.19) becomes

(15.20)

Selecting a linear interpolation profile for the variation of pressure, the pressure gradient term can be rewritten as a function of pressure values at the main grid points as

(15.21)

Thus either approach leads to the same expression involving the pressure difference between the alternating points E and W.

In a similar way, using a linear interpolation profile and noticing that the density is constant and $$ (\Delta y)_{e} = (\Delta y)_{w} = \, (\Delta y)_{C} $$, the continuity equation can be expressed as

(15.22)

which also relates the velocity at two alternating grid points.

In Eq. (15.21) the pressure gradient term in element C depends on the values of pressure at the two alternating, not consecutive, grid points straddling the element. The same is true for the continuity equation, which enforces conservation only for alternating velocity elements. This implies that non-physical zigzag (or checkerboard) pressure and velocity fields, like the ones shown in Fig. 15.2, will be sensed as uniform fields by the numerical scheme.

Fig. 15.2

A checkerboard pressure and velocity fields

For the pressure and velocity values shown in Fig. 15.2, the pressure gradient at points W, C, and E are found to be

and the continuity equation seems to be enforced for each element since

In multi dimensional situations a similar non-physical behavior can arise even if it is harder to visualize. This sets the ground for the next step that presents one approach to resolve this problem.

15.2.4 The Staggered Grid

The culprit in the previous formulation is the uncoupling between the pressure and velocity fields. Coupling can be enforced if the different variables are stored at staggered locations such that no interpolation is needed to calculate the pressure gradient in the momentum equation and the velocity field in the continuity equation. Such a staggered grid is shown in Fig. 15.3a, b. In the staggered grid the velocity field is stored at cell faces (Fig. 15.3a), while pressure and all other variables are stored at cell centroids (Fig. 15.3b).

Fig. 15.3

An element for a the momentum equation and b the continuity equation in a one dimensional staggered grid arrangement

With this formulation, the discretized continuity equation for element C becomes

(15.23)

with no need for interpolation as the velocity values are available at the e and w locations. Moreover, the momentum equation is integrated over elements similar to element e resulting in the following discretized momentum equation:

(15.24)

The pressure gradient is related to values at the consecutive grid points straddling the element face with no interpolation needed. Therefore checkerboard pressure and velocity field solutions are inadmissible as they will be easily detected and eliminated by the numerical method.

15.2.5 The Pressure Correction Equation

The derivations presented next are based on the work of Patankar and Spalding [2, 3], who developed the initial implementation of the SIMPLE (Semi Implicit Method for Pressure Linked Equations) algorithm.

Starting with the continuity and momentum equations given respectively by (Fig. 15.3)

(15.25)

(15.26)

the solution proceeds by providing an initial guess for the velocity and pressure fields. Denoting the initial guess or the solution at the starts of any iteration with a superscript (n), then the tentative velocity and pressure fields are given by u (n) and p (n). At any iteration, solving the momentum equation first for the velocity field, the solution obtained is denoted by a superscript * as it is not the final solution at the current iteration. Thus, the momentum equation satisfies

(15.27)

where the pressure field is still based on values from the previous iteration. The computed velocity field u * satisfies the momentum equation but not necessarily the continuity equation, since the pressure field is not exact. Therefore a correction is sought to ensure that the velocity (or the mass flow rate) and pressure fields satisfy the continuity equation.

Denoting the correction fields with a superscript prime, i.e., $$ \left( {u^{\prime},p^{\prime}} \right) $$, then the sought after velocity and pressure are given by

(15.28)

Note that the mass flow rate at cell faces will also be corrected according to

(15.29)

such that the exact mass flow rate satisfies the continuity equation, i.e.,

(15.30)

which can be rewritten as

(15.31)

This is an interesting form of the continuity equation showing that once the computed mass flow rate reaches the exact solution and satisfies the continuity equation, then the RHS becomes zero leading to a zero correction field. Thus it is the mass conservation error of the current fields that drives the correction field. The mass flow rates and mass flow rate corrections at an element faces are given by

(15.32)

and

(15.33)

where in Eqs. (15.32) and (15.33) the fact that $$ S_{e}^{x} =\Delta y_{e} $$ and $$ S_{w}^{x} = -\Delta y_{w} $$ has been used.

The pressure field does not appear in Eq. (15.31) and to bring it into the equation, the discrete form of the momentum equation is used. The process starts by rewriting Eq. (15.26) in a more compact form as

(15.34)

where

(15.35)

For the case of the computed velocity field, the above equation is written as

(15.36)

Subtracting the computed momentum equation, Eq. (15.36), from the exact one, Eq. (15.34), an equation for the correction field is obtained as

(15.37)

A similar approach is used for the w face yielding

(15.38)

Substituting Eq. (15.33) into the continuity equation, Eq. (15.31), its expanded form becomes

(15.39)

Then replacing the discrete forms of $$ u^{\prime}_{e} $$ and $$ u^{\prime}_{w} $$ computed from Eqs. (15.37) and (15.38), respectively, in Eq. (15.39), an equation involving pressure correction is obtained and is given by

(15.40)

In this equation the pressure field appears in a diffusion like form, which after discretization becomes

(15.41)

or

(15.42)

Rearranging, the pressure correction equation is formulated as

(15.43)

where

(15.44)

The underlined terms in Eqs. (15.37), (15.38), and (15.44) involve corrections which become zero at the state of convergence. Therefore they have no effect on the final solution. Different approximations to these terms result in different algorithms as will be explained later. In the original SIMPLE algorithm these terms are simply neglected. Moreover for one dimensional constant area situations Δy may be set to 1 and dropped from the equations.

15.2.6 The SIMPLE Algorithm on Staggered Grid

Using the momentum and pressure correction equations, a solution to the flow problem can be obtained. In the SIMPLE algorithm this solution is found iteratively by generating pressure and velocity fields that consecutively satisfy the momentum and continuity equations, while approaching the final solution (which satisfies both equations) at every iteration [4–6]. This sequential, rather than simultaneous, solution of the equations is denoted in the literature by the segregated approach. The sequence of events in the segregated SIMPLE algorithm can be summarized as follows:

1.

Start with a guessed pressure and velocity fields p (n) and u (n), respectively.

2.

Solve the momentum equation given by Eq. (15.27) to obtain a new velocity field $$ u_{f}^{*} $$.

3.

Update the mass flow rates using the momentum satisfying velocity field to obtain the $$ \dot{m}_{f}^{*} $$ field.

4.

Using the new mass flow rates solve the pressure correction equation to obtain a pressure correction field $$ p^{\prime} $$.

5.

Update the pressure and velocity fields to obtain continuity-satisfying fields using the following equations:

(15.45)

6.

set $$ u^{(n)} = u^{**} $$ and $$ p^{(n)} = p^{*} $$

7.

Go back to step 2 and repeat until convergence.

The SIMPLE algorithm is best illustrated via the example presented next.

Example 1

Flow in a Pipe Network

A portion of a water pipe system is shown in Fig. 15.4 . The momentum equation for the flow in the pipes can be written as

where D A  = 0.5, D B  = D F  = 0.4, D C  = D E  = 0.3, D D  = 0.19, D G  = 0.1875, and D H  = 0.35. Using the SIMPLE algorithm, calculate the unknown mass flow rates and pressures in the system.

Fig. 15.4

A portion of a water pipe system

Solution

In this system, the mass flow rate field is used as a variable instead of the velocity field. This is not problematic since the momentum equation has been simplified by dropping the convection and diffusion terms as their values are negligible compared to the pressure head.

The solution using the SIMPLE algorithm starts by first computing an initial velocity field using the assumed pressure field, and then predicting a pressure field that enforces continuity on the just computed velocity field.

This procedure is summarized as

1.

Start with a guessed pressure field.

2.

Compute the mass flow rates using the given momentum equation.

3.

Construct a pressure correction equation that enforces continuity (mass conservation) and use it to correct the pressure and velocity fields.

No iterations will be needed since there are no non-linear effects induced by a convection term.

step 1

Start by assigning guessed values to the pressure at the locations where solutions are to be found. Thus assume the following:

$$ \begin{array}{*{20}c} {p_{3}^{(n)} = 300} & {p_{6}^{(n)} = 200} & {p_{8}^{(n)} = 120} \\ \end{array} $$ (other values could have been used)

step 2

Based on the assumed pressure values calculate the various mass flow rates using the momentum equations according to

step 3

Check whether the mass flow rates satisfy continuity by computing $$ \sum\limits_{\sim k} {\dot{m}_{k}^{*} } $$ at all interior points, i.e.,

Since mass conservation is not satisfied, correction fields are needed and pressure correction equations are derived as follows:

In term of pressure corrections, mass flow rate corrections can be expressed as

Note that $$ p^{\prime}_{1} $$, $$ p^{\prime}_{2} $$, $$ p^{\prime}_{4} $$, $$ p^{\prime}_{5} $$ and $$ p^{\prime}_{7} $$ are set to zero since the corresponding pressure values are known and hence represent the exact values.

The flow field at nodes 3, 6, and 8 are respectively given by

and using pressure corrections as

After simplification the above equations become

Substituting the tentative mass flow rates, the various correction fields satisfy

Solving the system of pressure correction equations yields

With the pressure correction computed, the velocity and pressure fields can now be updated to produce a mass conserving velocity field. The mass flow rates are computed as

while the pressure is updated using

Treat the corrected values as a new guess and repeat. Better estimate for the mass flow rates are computed using the momentum equations as

The imbalance in the mass flow rate at nodes 3, 6, and 8 are computed as

The pressure correction equations become

The solution to the pressure correction field is found to be

Thus the solution is obtained in one iteration.

15.2.7 Pressure Correction Equation in Two Dimensional Staggered Cartesian Grids

In a two dimensional Cartesian grid, three grid systems are used. One for the u-velocity component, a second one for the v-velocity component, and a third grid system for the pressure and other variables as illustrated in Fig. 15.5.

Fig. 15.5

u, v, and p elements in a two dimensional Cartesian staggered grid

The derivations presented above for the pressure correction equation in one dimensional domains can be easily extended into multi dimensional situations. For element C shown in Fig. 15.6, the pressure correction equation is obtained as

(15.46)

where

(15.47)

Fig. 15.6

A two dimensional Cartesian element for the derivation of the pressure correction equation

Example 2

In the two dimensional problem shown in Fig. 15.7 , the following quantities are given u w  = 50, v s  = 20, p N  = 0 and p E  = 10.

The flow is steady and the density is uniform and equal to 1. The momentum equations for u e and v n are given by

where the constants d e  = 1 and d n  = 0.25. The element shown has Δx = Δy = 1. Use the SIMPLE algorithm to compute the values of u e , v n , and p C .

Fig. 15.7

The two dimensional domain used in Example 2

Solution

Start by assigning a guessed value to the pressure at the C location where solution is to be found. Thus assume the following:

$$ p_{C}^{(n)} = 100 $$ (other values could have been guessed)

Based on the assumed pressure value calculate the various velocities using the momentum equation according to

Since the density is uniform and equal to 1 and Δx = Δy = 1, then

Check whether the mass flow rates satisfy continuity over element C by computing $$ \sum\limits_{\sim f} {\dot{m}_{f}^{*} } $$ at the element faces.

In the above mass conservation equation the negative sign for $$ \dot{m}_{w}^{*} $$ and $$ \dot{m}_{s}^{*} $$ is explicitly used. Since mass conservation is not satisfied, correction fields are needed and a pressure correction equation is derived as follows:

In term of pressure corrections, mass flow rate corrections can be expressed as

The correction equation becomes

Applying the correction to the mass flow rate and pressure fields, continuity satisfying fields are obtained as

Treat the corrected values as a new guess and repeat.

The imbalance in the mass flow rate is computed as

The pressure correction equations become

The solution to the pressure correction field is found to be

Thus the solution is obtained in one iteration as

15.2.8 Pressure Correction Equation in Three Dimensional Staggered Cartesian Grid

Without going into details and for completeness of presentation, the pressure correction equation over the three dimensional staggered Cartesian grid shown in Fig. 15.8, where the u, v, and w velocity components are stored at the (e, w), (n, s), and (t, b) element faces, respectively, is given by

(15.48)

where

(15.49)

Fig. 15.8

A three dimensional Cartesian element for the derivation of the pressure correction equation

15.3 Disadvantages of the Staggered Grid

The use of staggered grids was critical to the development of the SIMPLE algorithm. Nevertheless adopting a staggered grid arrangement has its disadvantages. As mentioned above, in two and three dimensions, three and four staggered grid systems, respectively, are required with the velocity components integrated over different elements, as shown in Fig. 15.5 for a two dimensional situation.

Besides the memory requirement to store a grid system for every velocity component and a grid system for pressure and other variables, the staggering procedure itself becomes an issue for non-Cartesian grids and more so for unstructured grids.

In curvilinear grids, the use of Cartesian velocity components can lead to problems when one or more of the surfaces become aligned with the staggered velocity component as shown in Fig. 15.9.

Fig. 15.9

Staggered Cartesian velocity components in a curvilinear grid system

Therefore a better alternative in this case is to use either covariant or contra-variant curvilinear velocity components, as shown in Fig. 15.10a, b, respectively.

Fig. 15.10

Curvilinear coordinates a Covariant component and b contra-variant components

An example of staggering using contra-variant velocity components is shown in Fig. (15.11).

Fig. 15.11

Curvilinear velocities: staggering using contra-variant velocity components

Unfortunately complications arise when discretizing the momentum equations in curvilinear coordinates [1, 3, 4, 7], due to the increased complexity in the treatment of the diffusion term, and because the equations gain non-conservative terms.

Another option shown in Fig. 15.12 is to stagger all Cartesian velocity components in all directions so as to have all velocity components at all faces. This would double (in two dimensions) or triple (in three dimensions) the number of momentum equations to be solved. The problem is further complicated in the case of an unstructured grid. In this case there is no obvious staggering direction, and the only way for a staggering concept to apply is by changing the size of the cell elements used for the pressure and velocity components, or by resorting to staggering all velocity components along all the faces, again dramatically increasing the number of variables to be solved. Finally, the geometric information stored is more than doubled, as a new unstructured grid need to be used for the velocity components.

Fig. 15.12

Cartesian components defined at each face

It turns out that the use of a cell-centered collocated grid system (Fig. 15.13), where all variables are stored at the same location (the cell centroid), is a more attractive solution. It is worth noting that while the velocity components are stored at the centroids of the elements as is the case for pressure or any other variable, the mass flux, a scalar value, in a collocated grid is stored at the element faces. The mass flux can actually be viewed as a contra-variant component, except that in this case it is computed using a custom interpolation of the discrete momentum equation, known as the Rhie-Chow interpolation, which is the subject of the next section.

Fig. 15.13

Collocated grid arrangement

15.4 The Rhie-Chow Interpolation

The deficiency in the original collocated formulation presented earlier was in the linear interpolation used to calculate the velocities at the element faces. This interpolation resulted in decoupling the pressure and velocity values at the cell level giving rise to the checkerboard problem. In 1983, Rhie and Chow [8] reported on an interpolation procedure that allowed the formulation of the SIMPLE algorithm on a collocated grid [9–16]. In their method a dissipation term, representing the difference between two estimates of the cell face pressure gradient, is added to the linearly interpolated cell face velocity. As shown in Fig. 15.14 the two pressure gradient estimates are based on different grid stencils.

Fig. 15.14

The two pressure gradient estimates in the Rhie-Chow interpolation technique

This procedure will be shown to be equivalent to constructing a pseudo-momentum equation at the element face with its coefficients linearly interpolated from the coefficients of the momentum equations at the centroids of the elements straddling the face and its pressure gradient computed using a small grid stencil. In that respect, the Rhie-Chow interpolation simply mimics the small stencil pressure-velocity coupling of the staggered grid arrangement.

Starting with the discretized x-momentum equations for cells C and F, which are

(15.50)

A u f velocity equation similar to that of Eq. (15.50), with the pressure gradient linked to the local neighboring pressure values, as illustrated in Fig. 15.14, will have the following form:

(15.51)

Since in a collocated grid, the coefficients of this equation cannot be directly computed, they are approximated by interpolation from the coefficients of the neighboring nodes. Using a linear interpolation profile, these coefficients are computed as

(15.52)

Employing the values given in Eq. (15.52), the pseudo-momentum equation at the element face becomes

(15.53)

This is in all practical sense the momentum equation on a “staggered” grid, which is reconstructed using the collocated grid momentum coefficients.

In all above equations and for later use, values with an over bar are obtained by linear interpolation between the values at points C and F according to

(15.54)

where g C and g F are geometric interpolation factors related to the position of the element face f with respect to the nodes C and F, as explained in previous chapters.

Using Eq. (15.50), $$ \overline{{H_{f} }} $$ is rewritten as

(15.55)

where the coefficient approximation can be shown to be second order accurate, i.e.,

(15.56)

Substituting Eq. (15.55) into Eq. (15.53), the velocity at the element face using the Rhie-Chow interpolation method is obtained as

(15.57)

For a multi dimensional situation, similar interpolation formulae can be derived for the y and z velocity components and are given by

(15.58)

(15.59)

Equations (15.57)–(15.59) can be written in a vector form, more suitable for deriving the multi-dimensional pressure correction equation, as

(15.60)

where

(15.61)

and where ∇p f is computed as per Sect. 9.​4 using

(15.62)

and yielding a stencil in the CF direction formed only from the adjacent cell values p F and p C as

(15.63)

With the face velocities closely linked to the pressure of adjacent cells, checkerboard fields are inadmissible rendering solutions on collocated grids viable.

15.5 General Derivation

Before proceeding with the development of the multidimensional collocated pressure correction equation, the discretized multidimensional momentum equation is first presented.

15.5.1 The Discretized Momentum Equation

The momentum equation given by Eq. (15.2) is slightly modified and written as

(15.64)

The discretized form of Eq. (15.64) in the time interval [t − Δt/2, t + Δt/2] is sought over element C shown in Fig. 15.15.

Fig. 15.15

Element C in a general unstructured grid system

In Eq. (15.64), the three underlined expressions represent, from left to right, the unsteady, convection, and diffusion term, respectively. The discretization of these terms proceeds as presented in previous chapters. The remaining terms are evaluated explicitly and treated as sources. The volume integral of the second part of the shear stress term is transformed into a surface integral using the divergence theorem and then into a summation of surface fluxes as

(15.65)

where the expanded form of $$ \left( {\nabla {\mathbf{v}}} \right)_{f}^{\text{T}} \cdot {\mathbf{S}}_{f} $$ in a three dimensional coordinate system is given by

(15.66)

The volume integral of the pressure gradient is also treated as a source term and evaluated explicitly as

(15.67)

or transformed into a surface integral according to Eq. (2.​85) and computed as

(15.68)

The body force term is integrated directly over the control volume to yield

(15.69)

Using a first order Euler scheme for the discretization of the unsteady term, a HR scheme for the convection term implemented via the deferred correction approach, and decomposing the diffusion flux into an implicit part aligned with the grid and an explicit cross diffusion part, the discretized momentum equation is written in vector form as

(15.70)

where the coefficients are given by

(15.71)

with the face fluxes calculated using

(15.72)

and the element fluxes computed from

(15.73)

Even though the algebraic form of the momentum equation, Eq. (15.70), is linear, its coefficients depend on the velocity and pressure fields. This nonlinearity is handled by an iterative process during which the coefficients are calculated at the start of every iteration based on values of the dependent variables obtained in the previous iteration. This change in the values of the coefficients results in large changes in v and affects the rate of convergence to the degree of even causing divergence. To slow down the changes, under-relaxation can be applied when the transient time steps used are large. Denoting the under relaxation factor by λ v and adopting Patankar’s implicit relaxation approach, the under relaxed momentum equation can be written as

(15.74)

By redefining $$ a_{C}^{{\mathbf{v}}} $$ and $$ {\mathbf{b}}_{C}^{{\mathbf{v}}} $$ such that

(15.75)

the under-relaxed momentum equation can be rewritten as

(15.76)

For the derivation of the collocated pressure correction equation, the pressure gradient is taken out of the $$ {\mathbf{b}}_{C}^{{\mathbf{v}}} $$ source term and displayed explicitly to yield

(15.77)

Substituting back in Eq. (15.76), the momentum equation becomes

(15.78)

Defining the following vector operators:

(15.79)

Equation (15.78) is reformulated as

(15.80)

a form that will be useful in later derivations.

15.5.2 The Collocated Pressure Correction Equation

As in the case of a staggered grid, starting with guessed values or values obtained from the previous iteration $$ \left( {{\mathbf{v}}^{(n)} ,\dot{m}^{(n)} ,p^{(n)} } \right) $$, the momentum equation, Eq. (15.80), is first solved to obtain a momentum conserving velocity field v *. Thus the obtained solution satisfies

(15.81)

while the final solution should satisfy Eq. (15.80). The difference between these two equations is that the velocity field in Eq. (15.80) satisfies both the momentum and continuity equations while the one in Eq. (15.79) does not necessarily satisfy the continuity equation because of the linearization in which pressure and velocity are based on the previous iteration values. Therefore corrections to the velocity, mass flow rate, and pressure fields are needed to enforce mass conservation. Denoting these corrections by $$ \left( {{\mathbf{v^{\prime}}},p^{\prime},\dot{m}^{\prime}} \right) $$ the relations between the exact and computed fields can be written as

(15.82)

Substituting the mass flow rate given by Eq. (15.82) into Eq. (15.25), the continuity equation becomes

(15.83)

with the face velocity computed using the Rhie-Chow interpolation as

(15.84)

When the computed mass flow rate field is conservative, the RHS of Eq. (15.83) is zero yielding a zero correction field. On the other hand, an incorrect velocity field leads to an imbalance in mass and a nonzero value of the RHS of Eq. (15.83) implying the need for a correction field for conservation to be enforced.

Mass flow rate corrections can be written in terms of velocity corrections, which can be derived by subtracting Eq. (15.81) from Eq. (15.80) to yield

(15.85)

A similar equation holds for element F and is given by

(15.86)

The mass flow rate correction at a cell face can be expressed as

(15.87)

where the face velocity correction is obtained by subtracting Eq. (15.84) from Eq. (15.60) to give

(15.88)

Substitution of Eqs. (15.87) and (15.88) in Eq. (15.83), leads to the following form of the pressure correction equation:

(15.89)

In this equation the underlined part represents the effects of the neighboring velocity corrections on the velocity correction of the element under consideration. This influence becomes clearer by interpolating Eqs. (15.85) and (15.86) to the face yielding the following equivalent expression for the underline terms:

(15.90)

Substituting Eq. (15.90) in Eq. (15.89), the pressure correction equation is rewritten as

(15.91)

or more explicitly in the form

(15.92)

In Eq. (15.91) or (15.92) the treatment of the underlined term is critical to rendering the equation solvable. In the original SIMPLE algorithm it is neglected, thus linking the velocity correction at a point directly to pressure corrections. Because this is a correction equation the modification or dropping of the term will not affect the final solution, since at convergence the corrections become zero. However it will affect the convergence rate in that the larger is the neglected term the higher will be the error present in the approximation at each iteration.

The remaining terms in Eq. (15.91) or (15.92) can be easily treated. The coefficients of the pressure correction equation are obtained as per the discretization of the diffusion term in Chap. 8, specifically the treatment of anisotropic diffusion.

Thus the term on the LHS is modified into a gradient dot product of the form

(15.93)

The expanded expression of $$ {\mathbf{S^{\prime}}}_{f} $$ is given by

(15.94)

Working with $$ {\mathbf{S^{\prime}}}_{f} $$, the discretization of the pressure correction gradient term proceeds as usual resulting in

(15.95)

where the following decomposition of $$ {\mathbf{S^{\prime}}}_{f} $$ was used:

(15.96)

The type of decomposition could be any of those reviewed in Chap. 8, as will be detailed later. The underlined term, arising due to grid non-orthogonality, can either be neglected or retained. If neglected, it will not affect the final solution as it is a correction term. If retained, then it will be treated explicitly with an internal loop (non-orthogonal loop in OpenFOAM®). As the solution starts with a zero pressure correction field at every iteration, the term has to be updated iteratively while solving the equation.

Dropping the non-orthogonal contribution, the linearized term of the pressure correction equation becomes

(15.97)

Substituting back in Eq. (15.91) the algebraic form of the pressure correction equation is obtained as

(15.98)

with the coefficients given by

(15.99)

Note that different approximations to the underlined terms in Eq. (15.99) result in different algorithms. In the original SIMPLE algorithm these terms are simply neglected.

Finally the mass flow rate $$ \dot{m}_{f}^{*} $$ in Eq. (15.99), is the one computed after solving the momentum equation using as usual the Rhie-Chow interpolation technique with the latest velocity field, i.e.,

(15.100)

Following the calculation of the pressure correction field, the pressure and velocity at the element centroids and the mass flow rate at the element faces are all corrected. As mentioned above, the underlined term in Eq. (15.99) is neglected in the SIMPLE algorithm resulting in large pressure correction values that may slow the rate of convergence or cause divergence. To increase robustness and improve the convergence behavior, pressure correction values obtained from Eq. (15.98) are explicitly under relaxed. No under relaxation is used when updating the velocity and mass flow rate fields since the pressure correction will ensure mass conservation for these fields. Denoting the under relaxation factor by λ p , the following correction equations are used:

(15.101)

15.5.3 Calculation of the $$ {\mathcal{D}}_{f} $$ Term

The type of decomposition suggested in Eq. (15.96) could be any of those reviewed in Chap. 8 with different approaches leading to different expressions for $$ {\mathcal{D}}_{f} $$ as derived below.

15.5.3.1 Minimum Correction Approach

For this approach E f is obtained by substituting $$ {\mathbf{S^{\prime}}}_{f} $$ for S f in Eq. (8.​68) leading to

(15.102)

where e CF is a unit vector in the CF direction. Combining Eqs. (15.94), (15.102), and (8.​64), E f becomes

(15.103)

Using Eq. (15.103), the following expression for $$ {\mathcal{D}}_{f} $$ is derived:

(15.104)

15.5.3.2 Orthogonal Correction Approach

The definition of E f in this case is obtained from Eq. (8.​69) and written as

(15.105)

Combining Eqs. (15.105), (15.94), and (8.​64), $$ {\mathcal{D}}_{f} $$ is found to be

(15.106)

15.5.3.3 Over-Relaxed Approach

In this method, E f is computed from Eqs. (8.​64) and (8.​70) as

(15.107)

Combining Eq. (15.107) with Eq. (15.94), $$ {\mathcal{D}}_{f} $$ is found to be

(15.108)

Any of the above approaches can be adopted to calculate the value of $$ {\mathcal{D}}_{f}. $$

15.5.4 The Collocated SIMPLE Algorithm

The sequence of events in the collocated SIMPLE algorithm is displayed in Fig. 15.16 and can be summarized as follows:

Fig. 15.16

A flow chart of the SIMPLE algorithm

1.

To compute the solution at iteration n + 1, start with the solution at time t for pressure, velocity, and mass flow rate fields, i.e., p (n), u (n), and $$ \dot{m}^{(n)} $$, respectively, as the initial guess.

2.

Solve the momentum equation given by Eq. (15.70) to obtain a new velocity field v *.

3.

Update the mass flow rate at the element faces using the Rhie-Chow interpolation (Eq. 15.100) to compute a momentum satisfying mass flow rate field $$ \dot{m}^{*} $$.

4.

Using the new mass flow rates assemble the pressure correction equation (Eq. 15.98) and solve it to obtain a pressure correction field $$ p^{\prime} $$.

5.

With the pressure correction field update the pressure and velocity fields at the element centroids and the mass flow rate at the element faces to obtain continuity-satisfying fields using Eq. (15.101). These resulting fields are denoted by u **, $$ \dot{m}^{**} $$, and p *, respectively.

6.

Treat the obtained solution as a new initial guess, return to step 2 and repeat until convergence.

7.

Set the solution at time n + 1 (i.e., t + Δt) to be equal to the converged solution and set the current time n + 1 (i.e., t + Δt) to be n (i.e., t).

8.

Advance to the next time step.

9.

Return to step 1 and repeat until the last time step is reached.

Example 3

In the two dimensional problem shown below, the following quantities are given p W  = 100, p N  = 20 and p E  = 50 and an inlet condition at face s with v s  = 20 and zero pressure gradient.

The flow is steady state and the density is uniform of value 1. The momentum equations for u e and v n are

and

where the constants d x  = 1 and d y  = 0.25. The element shown has Δx = Δy = 1. Use the collocated SIMPLE algorithm to derive the pressure correction equation and solve it to find the pressure for element C. Take $$ p_{C}^{(n)} = 70 $$ as an initial guess for pressure at C (Fig. 15.17).

Fig. 15.17

The two dimensional domain used in Example 3

Solution

At the inlet the zero gradient condition can be used to compute

now compute $$ u_{C}^{(n)} ,v_{C}^{(n)} $$ using

and

since $$ p_{e}^{(n)} = 0.5\left( {p_{E}^{(n)} + p_{C}^{(n)} } \right),\;p_{n}^{(n)} = 0.5\left( {p_{E}^{(n)} + p_{N}^{(n)} } \right) $$ and $$ {p}_{w}^{(n)} = 0.5\left( {p_{E}^{(n)} + p_{W}^{(n)} } \right) $$

Now the pressure correction equation is constructed by substituting the mass flux and its correction into the mass conservation equation. Using the Rhie-Chow interpolation the face fluxes are computed as

similarly for the n and w face

with $$ \dot{m}_{s} = - 20\Delta x = - 20 $$ the pressure correction equation is constructed from

and

now

thus we have

or

if the E, N and W values were exact then we would have

or

then we would proceed with correcting the pressure and velocity components at C to yield

so

15.6 Boundary Conditions

A boundary element has at least one face located at a boundary patch, which is denoted as a boundary face (Fig. 15.18). The treatment of boundary conditions at a boundary face is critical to the accuracy and robustness of any CFD code. Thus for any pressure-based code to succeed, it is imperative for the boundary conditions of both momentum and pressure-correction equations to be properly implemented. This section describes in detail the implementation of a variety of boundary conditions.

Fig. 15.18

An example of a boundary element

A first note of interest is the expression of the Rhie-Chow interpolation at a boundary face, which has to be modified since the averaging cannot be performed in a fashion similar to an interior face. The average at a boundary face is written in terms of the element value as

(15.109)

where b refers to the boundary face centroid and C to the element centroid. Adopting this practice, the averages in the Rhie-Chow interpolation, the velocity, and the mass flow rate at a boundary face become

(15.110)

(15.111)

(15.112)

In what follows the implementation of boundary conditions is first presented for the momentum equation, followed by the implementation of the boundary conditions for the pressure (correction) equation. For the cases when the boundary conditions for the momentum and pressure correction equations are co-dependent, their full treatment is detailed in the pressure correction equation section.

15.6.1 Boundary Conditions for the Momentum Equation

The semi-discretized form of the momentum equation can be expressed as

(15.113)

where the discretization type of the various terms is explicitly stated. Terms that are evaluated at the element faces should be modified along a boundary face in accordance with the type of boundary condition used. Therefore, for boundary elements, the terms evaluated at the element faces are written as

(15.114)

(15.115)

(15.116)

where subscript b refers to a value at the boundary. As previously stated, the pressure term may be discretized following either an element or a face discretization. In either case the expanded form is the same since $$ V_{C} \left( {\nabla p} \right)_{C} $$ is calculated as $$ \sum\limits_{f\sim nb(C)} {p_{f} {\mathbf{S}}_{f} } $$ implying that the value at the boundary is always required. To show the way boundary pressure affects solution, the expanded form of the pressure gradient (i.e., face discretization) is adopted in the implementation of boundary conditions.

15.6.1.1 Wall Boundary Conditions

Generally a no-slip or a slip boundary condition may be applied to a moving or a stationary wall. The implementation involves computing and linearizing the shear stress at the wall. This is different from the Dirichlet condition, though for a cartesian grid the two conditions may be shown to be identical.

No-Slip Wall Boundary $$ \left( {p_{b} = ?;\dot{m}_{b} = 0;{\mathbf{v}}_{b} = {\mathbf{v}}_{wall} } \right) $$

A no slip boundary condition implies that the velocity of the fluid at the wall v b is equal to the velocity of the wall v wall . For a stationary wall, the boundary velocity v b is zero. The known velocity at the wall could be wrongly viewed as a Dirichlet boundary condition. However this is not really the case, since what is needed is to have a zero normal boundary flux while also accounting for the shear stress. This cannot be satisfied by simply setting v b  = v wall . Figure 15.19 shows that this can be guaranteed by ensuring a shear stress that is tangential to the wall in addition to a boundary velocity equation that is equal to the wall velocity. The force F b exerted by the wall on the fluid can be written as

(15.117)

where $$ {\mathbf{F}}_{\parallel } $$ is in the tangential direction to the wall and $$ {\mathbf{F}}_{ \bot } $$ is in the normal direction, which is supposed to be zero. Thus

(15.118)

where $$ \tau_{wall} $$ is the shear stress exerted by the wall on the fluid given by

(15.119)

Fig. 15.19

A schematic of a no-slip wall boundary condition

In Eq. (15.119) $$ {\mathbf{v}}_{\parallel } $$ is the velocity vector in the direction parallel to the wall and $$ d_{ \bot } $$ is the normal distance from the centroid of the boundary element to the wall computed as

(15.120)

and $$ {\mathbf{n}}$$ the wall normal unit vector. The velocity vector $$ {\mathbf{v}}_{\parallel } $$ can be written as the difference between v and its normal component as

(15.121)

From Eq. (15.119), the wall shear stress can be approximated using

(15.122)

from which the boundary force for a laminar flow can be obtained as

(15.123)

Using Eq. (15.123) the coefficients of the boundary elements for the momentum equation in the x, y and z directions are modified as follows:

u-component equation

(15.124)

v-component equation

(15.125)

w-component equation

(15.126)

The unknown boundary pressure p b is extrapolated from the interior solution using either a truncated Taylor series expansion around point C such that pressure is found from

(15.127)

or the mass flow rate expressed via the Rhie-Chow interpolation as

(15.128)

Since the mass flow rate and velocity at the wall boundary are zero, the above equation reduces to

(15.129)

which can be modified into

(15.130)

Expressing $$ {\mathbf{S^{\prime}}}_{b} $$ as the sum of the two vector E b and T b , Eq. (15.130) becomes

(15.131)

Since E b is in the direction of Cb, the above equation can be modified to

(15.132)

from which the boundary pressure is obtained as

(15.133)

Slip Wall Boundary $$ \left( {p_{b} = ?;\dot{m}_{b} = 0;{\mathbf{F}}_{b} = 0} \right) $$

For this boundary condition, the wall shear stress is zero (Fig. 15.20). Therefore the boundary force is zero. The boundary pressure is computed as for the no-slip wall boundary case using Eq. (15.127) or Eq. (15.133). The coefficients of the momentum equation (in vector form) are modified as follows:

Fig. 15.20

A schematic of a slip wall boundary condition

(15.134)

15.6.1.2 Inlet Boundary Conditions

Three types of inlet boundary conditions are considered. (i) specified velocity; (ii) specified static pressure and velocity direction; and (iii) specified total pressure and velocity direction. All treatments of the pressure boundary conditions will be detailed in the pressure correction boundary conditions section.

Specified Velocity $$ \left( {p_{b} = ?;\dot{m}_{b} \,specified;{\mathbf{v}}_{b} \,specified} \right) $$

For a specified velocity boundary condition at inlet (Fig. 15.21) the convection $$ \left( {\dot{m}_{b} {\mathbf{v}}_{b} } \right) $$ and diffusion $$ \left( {{\mathbf{F}}_{b} = \tau_{b} \cdot {\mathbf{S}}_{b} } \right) $$ terms at the boundary face are calculated using the known values of velocity v b and mass flow rate $$ \dot{m}_{b} $$. The pressure at the boundary is extrapolated from the boundary element centroid as

Fig. 15.21

A schematic of specified velocity boundary condition at inlet

(15.135)

The terms involving the boundary velocity are treated explicitly by adding them to the source term and setting the coefficient $$ a_{F = b}^{{\mathbf{v}}} $$ to zero while adding its value to the $$ a_{C}^{{\mathbf{v}}} $$ coefficient.

The coefficients of the boundary element are modified according to

(15.136)

Specified Pressure and Velocity Direction $$ \left( {p_{b}} = p_{specified} ;\;\right. \left.{\dot{m}_{b} ?;{\mathbf{e}}_{{\mathbf{v}}} \;specified;{\mathbf{v}}_{b} ?} \right) $$

In the case of a specified static pressure at inlet (Fig. 15.22), p b is known. The velocity being unknown, has to be computed from the pressure gradient at the boundary. To this end, a velocity direction should be specified as part of the boundary condition.

Fig. 15.22

A schematic of specified pressure and velocity direction boundary condition at inlet

As the boundary pressure p b is known, its value is directly used in calculating the pressure gradient in the boundary element without any special treatment. Therefore p b is used in calculating $$ \nabla p_{C} $$.

The mass flow rate at the boundary is computed from the continuity equation (see next section). Then, for a specified velocity direction given by the unit vector e v , the velocity for a specified pressure boundary condition at inlet is obtained as

(15.137)

The velocity at the boundary is computed at every iteration and the problem is solved as in the case of a specified velocity with the coefficients in the momentum equation modified according to Eq. (15.136).

Specified Total Pressure and Velocity Direction $$ \left( {p_{o,b}} = p_{o,specified} ; \right. $$ $$ \left.{\dot{m}_{b} ?;{\mathbf{e}}_{{\mathbf{v}}} \;specified;{\mathbf{v}}_{b} ?} \right) $$

In the case of a specified total pressure at inlet (Fig. 15.23) the velocity direction should also be specified. However, the magnitude of the velocity and the pressure at the boundary are unknown though related using the total pressure definition given by

(15.138)

where p ₀ is the total pressure, p the static pressure, ρ the density, and v the velocity vector. The mass flow rate at the boundary is computed from the continuity equation (see next section). Knowing the mass flow rate, the velocity is computed in the same manner as for the specified pressure case using Eq. (15.137). The velocity is thus treated as a known velocity condition (i.e., a Dirichlet boundary condition) with the coefficients in the momentum equation modified according to Eq. (15.136).

Fig. 15.23

A schematic of specified total pressure and velocity direction boundary condition at inlet

15.6.1.3 Outlet Boundary Conditions

Three types of boundary conditions at an outlet are considered: (i) a specified static pressure, (ii) a specified mass flow rate, and (iii) a fully developed flow.

Specified Static Pressure $$ \left( {p_{b} = p_{specified} ;\dot{m}_{b} ?;{\mathbf{v}}_{b} ?} \right) $$

For the momentum equation, fully developed conditions are assumed at a specified pressure outlet (Fig. 15.24) implying a zero velocity gradient along the direction of the surface vector at outlet. This is also equivalent to assuming the velocity at the outlet to be equal to that of the boundary element. Thus it is similar to a zero flux boundary condition whose implementation is rather simple.

Fig. 15.24

A schematic of specified static pressure boundary condition at outlet

The modifications to the coefficients are given by

(15.139)

This sets the contribution of the outlet velocity to zero and uses the specified pressure boundary value in the computation of the pressure gradient.

However to ensure that the flux is zeroed in the outflow surface vector direction only, the velocity is usually extrapolated to the outlet using the boundary flux, which is computed from the boundary element flux as

(15.140)

This ensures that the gradient along the boundary surface vector is zero. Then, using a Taylor series expansion, the velocity at the boundary is computed as

(15.141)

where $$ \nabla {\mathbf{v}}_{b} $$ is used instead of $$ \nabla {\mathbf{v}}_{C} $$. Therefore an additional correction is now added to the source term and the modifications to the coefficients become

(15.142)

Specified Mass Flow Rate $$ \left( {\dot{m}_{b} = \dot{m}_{specified} ;p_{b} ?{\mathbf{v}}_{b} ?} \right) $$

Since the flow is incompressible, a specified mass flow rate boundary condition (Fig. 15.25) is equivalent to specifying the normal component of velocity at the boundary. The velocity is calculated by assuming its direction to be the same as that at the main grid point, i.e., $$ \left( {{\mathbf{e}}_{{\mathbf{v}}} } \right)_{b} = \left( {{\mathbf{e}}_{{\mathbf{v}}} } \right)_{C} $$. Thus, the velocity is expressed as

(15.143)

with $$ \left| {{\mathbf{v}}_{b} } \right| $$ obtained from

(15.144)

allowing v b to be calculated. Thus for momentum, a specified velocity boundary condition is applied. The coefficients of the boundary elements are modified according to Eq. (15.136).

Fig. 15.25

A schematic of specified mass flow rate boundary condition at outlet

Fully Developed Outlet Flow

For a fully developed flow, the velocity gradient normal to the outlet surface is assumed to be zero. Hence the velocity at the outlet is assumed to be known and computed from the zero normal gradient using Eqs. (15.140) and (15.141). As for the pressure at the boundary, it can be extrapolated from the interior pressure field using

(15.145)

The velocity is treated as known and the coefficients of the momentum equation are modified according to Eq. (15.142).

15.6.1.4 Symmetry Boundary Condition

A scalar is reflected across a symmetry boundary. Thus, a symmetry boundary condition for a scalar variable is imposed by setting its normal gradient to zero, as with an insulated wall boundary condition. For the velocity vector, the symmetry condition shown in Fig. 15.26 also implies that it is reflected about the symmetry boundary with its parallel component (i.e., parallel to the symmetry boundary) retaining magnitude and direction, while its normal component becoming zero. This results in a zero shear stress but a non-zero normal stress along the symmetry boundary. Thus, the same boundary condition can be used to impose a slip wall boundary condition for viscous flows.

Fig. 15.26

A schematic of a symmetry boundary condition

The unit vector in the direction normal to the boundary $$ {\mathbf{n}}$$ and the normal distance to the boundary $$ d_{ \bot } $$ are given by Eq. (15.120). Therefore the velocity components normal and parallel to a symmetry boundary satisfy

(15.146)

The normal component of velocity can be written as

(15.147)

while the parallel component is given by Eq. (15.121). The boundary force F b can be decomposed into a normal component $$ {\mathbf{F}}_{ \bot } $$ and a parallel component $$ {\mathbf{F}}_{||} $$. As the shear stress along a symmetry boundary is zero, the parallel component of F b is zero. Denoting the normal stress by $$ \sigma_{ \bot } $$, the force F b is given by

(15.148)

The normal stress component can be approximated as

(15.149)

from which the boundary force is found to be

(15.150)

The pressure gradient in the direction normal to a symmetry boundary is zero. Mathematically this is written as

(15.151)

The pressure at a symmetry boundary should be extrapolated from the interior of the domain. Therefore to ensure a zero normal gradient, the pressure gradient at the symmetry boundary is computed as

(15.152)

Thus, the pressure is obtained from

(15.153)

Using the above equations, the coefficients of the boundary elements for the momentum equation in the x, y and z directions are modified as follows:

u-component equation

(15.154)

v-component equation

(15.155)

w-component equation

(15.156)

While this is not a comprehensive list of momentum boundary conditions, it does cover the most common types.

15.6.2 Boundary Conditions for the Pressure Correction Equation

The continuity equation for a boundary cell can be written as

(15.157)

or

(15.158)

where $$ \dot{m}_{b}^{*} $$ is the boundary mass flux and $$ \dot{m}^{\prime}_{b} $$ is its correction. While for an internal face the mass flux and its correction are defined by Eqs. (15.100) and (15.101), for a boundary face the definition is slightly different. Since at a boundary face only the boundary cell contributes to the average quantities, the use of Eq. (15.109) in combination with Eqs. (15.100) and (15.101) gives

(15.159)

In implementing boundary conditions the values of $$ \dot{m}_{b}^{*} $$, $$ \dot{m}^{\prime}_{b} $$, p b , and $$ p^{\prime}_{b} $$ must be calculated. Based on the discussions related to the momentum equation, three types of boundary conditions can be inferred. The first type is designated by “specified mass flow rate” (e.g., walls or velocity specified at inlets). For this category $$ \dot{m}^{\prime}_{b} = 0 $$, which is similar to a zero scalar flux boundary condition, and no modification to the pressure-correction equation is needed. The pressure however has to be computed at the boundary from the interior field. The second type of boundary conditions is termed “pressure specified” where $$ p^{\prime}_{b} = 0 $$ and for which a Dirichlet-like condition has to be enforced for the pressure-correction equation. For this condition, $$ \dot{m}_{b}^{*} $$ is computed from the boundary and interior pressure field. In the third type, an implicit relation exists between the pressure and the mass flow rate, as in a specified total pressure boundary condition. In this case, an explicit equation is extracted from the implicit relation and substituted into the pressure-correction equation.

Details regarding the various types of boundary conditions and their implementation are now given.

15.6.2.1 Wall Boundary Condition

Whether it is a slip (Fig. 15.20) or no-slip (Fig. 15.19) wall boundary condition the mass flow rate is zero. Therefore $$ \dot{m}^{\prime}_{b} = 0 $$, which is equivalent to a specified zero flux and implying that no modification is needed for the pressure-correction equation. However the pressure at the wall is required and is computed using Eq. (15.127) or Eq. (15.133) or a low order extrapolation profile, as shown below.

(15.160)

15.6.2.2 Inlet Boundary Conditions

Specified Velocity $$ \left( {p_{b} = ?;\dot{m}_{b}\, specified;{\mathbf{v}}_{b} \,specified} \right) $$

For a specified velocity at inlet (Fig. 15.21), the mass flux is known and its correction is set to zero, i.e., $$ \dot{m}^{\prime}_{b} = 0 $$. Thus, similar to a wall boundary condition, the term is simply dropped from the pressure-correction equation. The pressure at the boundary is extrapolated from the internal pressure field using Eq. (15.127) or Eq. (15.133) or a low order extrapolation profile as summarized in Eq. (15.160).

Specified Pressure and Velocity Direction $$ \left( {p_{b}} = p_{specified} ;\right. $$ $$ \left.{\dot{m}_{b} ?;\,{\mathbf{e}}_{{\mathbf{v}}} \,specified;{\mathbf{v}}_{b} ?} \right) $$

In the case of a specified static pressure at inlet (Fig. 15.22), p b is known and thus $$ p^{\prime}_{b} $$ is set to zero but $$ \dot{m}^{\prime}_{b} \ne 0 $$. The inlet is treated as a Dirichlet boundary condition for the pressure-correction equation. The coefficient of the $$ p^{\prime} $$ equation becomes

(15.161)

Specified Total Pressure and Velocity Direction $$ \left( {p_{o,b}} = p_{o,specified} ;\right. \;\left.{\dot{m}_{b} ?;\;{\mathbf{e}}_{{\mathbf{v}}} \,specified;{\mathbf{v}}_{b} ?} \right)$$

As mentioned earlier, for a specified total pressure (Fig. 15.23), the velocity direction should also be specified. The total pressure relation given by Eq. (15.138) is first rewritten as a function of the mass flow rate and pressure by replacing the velocity magnitude by the mass flux. Thus,

(15.162)

Using a Taylor expansion about p b , $$ p^{\prime}_{b} $$ is obtained as

(15.163)

Differentiating Eq. (15.162) with respect to $$ \dot{m}_{b} $$ and substituting into Eq. (15.163), the final form of $$ p^{\prime}_{b} $$ is found to be

(15.164)

Substituting Eq. (15.164) in Eq. (15.159), the mass flux correction is expressed as

(15.165)

Replacing $$ \dot{m}_{b}^{\prime} $$ in the expanded continuity equation (Eq. 15.158) by its expression from Eq. (15.165), the modified $$ a_{C}^{{p^{\prime}}} $$ coefficient for the boundary cell becomes

(15.166)

15.6.2.3 Outlet Boundary Conditions

Specified Pressure $$ \left( {p_{b} = p_{specified} ;\dot{m}_{b} ?; \;{\mathbf{v}}_{b} ?} \right) $$

For a specified pressure at outlet (Fig. 15.24) $$ p^{\prime}_{b} $$ is set to zero. On the other hand, $$ \dot{m}^{\prime}_{b} $$ is computed as

(15.167)

The velocity direction being needed, it is customary to take the direction of v b to be that of the upwind velocity v C . The expression of the $$ a_{C}^{{p^{\prime}}} $$ coefficient in the pressure-correction equation becomes

(15.168)

Specified Mass Flow Rate $$ \left( {\dot{m}_{b} = \dot{m}_{specified} ;p_{b} ?{\mathbf{v}}_{b} ?} \right) $$

For a specified mass flow rate at outlet (Fig. 15.25), $$ \dot{m}^{\prime}_{b} $$ is zero and is simply dropped from the pressure correction equation with no modifications required for the coefficients of the boundary elements. By setting $$ \dot{m}^{\prime}_{b} $$ to zero in Eq. (15.159), the pressure correction (or pressure) at the boundary is set equal to the pressure correction (or pressure) at the boundary cell centroid.

Fully Developed Outlet Flow

For a fully developed flow, the velocity at the outlet is assumed to be known and computed from the zero normal gradient. This means that $$ \dot{m}_{b} $$ at the outlet is known. Therefore no correction is needed and $$ \dot{m}^{\prime}_{b} $$ is set to zero. However, as the boundary pressure is unknown, it is extrapolated from the interior pressure field. Since the velocity is iteratively updated, the above treatment does not guarantee overall conservation except at convergence. It is customary with incompressible flows to overcome this issue and to enforce global mass conservation at any iteration by modifying $$ \dot{m}_{b} $$ at the boundary to satisfy overall mass conservation. This is done by calculating the total mass flow rate entering the domain $$ \sum {\dot{m}_{in} } $$. Then based on the calculated mass flow rates at outlet boundaries, the total mass flow rate leaving the domain $$ \sum {\dot{m}_{out} } $$ is computed. The mass flow rate at an outlet is adjusted according to

(15.169)

To be able to apply the above treatment, the outlet should be placed far away from any recirculation zone.

15.6.2.4 Symmetry Boundary Condition

The mass flow rate across a symmetry line (Fig. 15.26) is zero and as such its correction is set to zero, i.e., $$ \dot{m}^{\prime}_{b} = 0 $$. Thus, similar to a wall boundary condition, the mass flow rate correction term is simply dropped from the pressure-correction equation. The pressure at the boundary is extrapolated from the internal pressure field using Eq. (15.127) or Eq. (15.133) or a low order extrapolation profile as summarized in Eq. (15.160).

15.6.2.5 The Relative Nature of Pressure

For incompressible flow problems in which the normal velocities are prescribed on all boundaries, a difficulty arises due to the relative nature of pressure. In such cases, since only the pressure gradient appears in the momentum equation, there is no means for determining the absolute level of pressure, and only pressure differences have physical meaning. This indeterminacy of the pressure level leads to a singular coefficient matrix A and the direct solution of the system $$ {\mathbf{A}}\phi = {\mathbf{b}} $$ fails. The singularity is easily removed by simply setting the pressure at one point in the domain to a prescribed value. The remaining pressures are then calculated relative to this value.

15.7 The SIMPLE Family of Algorithms

In the SIMPLE algorithm [13], velocity and pressure are treated in a segregated (sequential) manner, with the pressure field computed by deriving a pressure correction equation that exploits the discrete momentum equation to replace the velocity field in the continuity equation with a pressure term. In the derivation, a velocity correction term, $$ \overline{{{\mathbf{H}}_{f} }} [{\mathbf{v^{\prime}}}] $$, was neglected as retaining it renders the equation unmanageable.

Discarding this term does not affect the final solution since its value is zero at convergence. Rather, it affects the path to convergence because during the initial iterations its value can be significant. This large value may either cause divergence or slow down the rate of convergence as a result of an overestimated pressure correction field. To counterbalance that, in SIMPLE the pressure is under relaxed by computing its value using $$ p = p^{*} + \lambda^{p} p^{\prime} $$, where $$ \lambda^{p} $$ is the pressure under relaxation factor. For optimum convergence, $$ \lambda^{p} $$ is usually set equal to $$ ( 1 { }{-}\lambda^{{\mathbf{v}}} ) $$, where $$ \lambda^{{\mathbf{v}}} $$ is the momentum under relaxation factor, with more information on this provided later.

Despite the use of under relaxation, the rate of convergence of the SIMPLE algorithm remains problem dependent and researchers sought alternatives for further improvements. Their effort culminated in the development of a SIMPLE-like family of algorithms such as SIMPLEC [17], SIMPLER [3], PISO [18], SIMPLEX [5], PRIME [19], SIMPLEM [20], and SIMPLEST [21]. Moukalled and Darwish [22] unified the formulation of these algorithms for both incompressible and compressible flows while Darwish et al. [23] and Jang et al. [24] assessed their performance. It is not the intention here to give a full account of these algorithms, rather, attention will be focussed on the two most popular variants, which are the SIMPLEC (SIMPLE Consistent) algorithm of Van Doormal and Raithby and the PISO (Pressure-Implicit Split Operator) algorithm of Issa. These two algorithms present two different approaches for dealing with the $$ \overline{{{\mathbf{H}}_{f} }} [{\mathbf{v^{\prime}}}] $$ term. In SIMPLEC the velocity correction at the main grid point is approximated as the weighted average of the velocity corrections at the neighboring locations altering the term $$ \overline{{{\mathbf{H}}_{f} }} [{\mathbf{v^{\prime}}}] $$ into a modified one, $$ {\tilde{\mathbf{H}}}_{f} [{\mathbf{v^{\prime}}}] $$, of smaller magnitude, which is then neglected. In the PISO algorithm, the $$ \overline{{{\mathbf{H}}_{f} }} [{\mathbf{v^{\prime}}}] $$ term is accounted for as part of the split operator approach. In all other algorithms, the $$ \overline{{{\mathbf{H}}_{f} }} [{\mathbf{v^{\prime}}}] $$ term is neglected as in SIMPLE and modifications are introduced either to the momentum equations or the D v operator. Because the PISO algorithm is equivalent to one step of the SIMPLE algorithm and one or more steps of the PRIME algorithm, the latter is also detailed.

In the PRIME [19] algorithm the momentum equation is solved explicitly. This explicit treatment of the momentum equation is justified by its small contribution to the convergence of the entire flow field. On the other hand, finding the correct solution for the pressure field represents the most important factor impacting the overall convergence.

In SIMPLEST [21], the coefficients in the momentum equation are separated into their convection and diffusion parts with the convection terms treated explicitly and the diffusion terms implicitly, thus affecting D v and H. The justification for the explicit treatment of convection is based on the similarity between the propagation of disturbances at a finite speed without any change in magnitude in a pure convection situation, and the propagation of error, from a particular point to the neighboring grid points, in a single iteration of explicit iterative methods. While the implicit treatment of diffusion is argued based on the similarity between the propagation of disturbances in a pure diffusion situation instantaneously in all directions with rapid decay in their amplitude and the reduction of errors throughout the entire solution domain, in a single iteration, by implicit solution methods.

In SIMPLEM (SIMPLE-Modified) [20], the pressure-correction equation is solved before the momentum equation implying that the pressure field is computed using the old velocity field. This results in better pressure corrections than velocity corrections and interchange the disadvantages and advantages of the SIMPLE algorithm.

In SIMPLER (SIMPLE-Revised) [3], an additional equation is developed from which the pressure is directly calculated while the SIMPLE-like pressure-correction equation is used to update the velocity field. The reason for a separate pressure equation being that, once the velocity field is updated using the predicted pressure correction field, it no longer satisfies the momentum equations. Therefore, the pressure should be calculated from another equation to match the velocities, so that the momentum equations are also satisfied.

The SIMPLEX algorithm [5] was developed with the aim of ensuring that the rate of convergence will not degrade with grid refinement. It differs from SIMPLE in the way the D v field is computed. This is done by using an additional set of equations, which is developed and solved based on the assumption that the influence of the spatial distribution of pressure difference changes little with grid refinement. Therefore, if the pressure difference influence is restricted to a cell, it would be appropriate to assume that, by extrapolation, the pressure difference at the main grid point adequately represents the pressure differences at the element faces.

Though all of the above algorithms were originally derived for a segregated grid, they are applicable within a collocated grid framework.

15.7.1 The SIMPLEC Algorithm

The SIMPLEC (SIMPLE-Consistent) [17] algorithm is a modified version of the SIMPLE algorithm derived by simply assuming that the velocity correction at point C is the weighted average of the corrections at the neighboring grid points. Mathematically this is expressed by

(15.170)

and using the H operator, Eq. (15.170) can be written as

(15.171)

Therefore instead of neglecting the $$ \overline{{{\mathbf{H}}_{C} }} [{\mathbf{v^{\prime}}}] $$ term as in SIMPLE, it is replaced by the approximate value given by the above equation. With this approximation the velocity correction given by Eq. (15.85) becomes

(15.172)

Equation (15.172) can then be used to derive the pressure correction equation.

The same result can be achieved by adding and subtracting the term $$ \sum\limits_{F \sim NB(C)} {a_{F}^{{\mathbf{v}}} {\mathbf{v}}_{C} } $$ from the momentum equation obtained by combining Eqs. (15.76) and (15.77), leading to the following modified equation:

(15.173)

which, in turn, can be written as

(15.174)

By using Eq. (15.174), the velocity correction equation becomes

(15.175)

Then the term $$ {\tilde{\mathbf{H}}}_{C} [{\mathbf{v^{\prime}}} - {\mathbf{v^{\prime}}}_{C} ] $$ is dropped, which is equivalent to the approximation given by Eq. (15.171), and the modified velocity correction is used in deriving the pressure correction equation.

Due to a better estimate in SIMPLEC (i.e., a smaller term is dropped), the relaxation of pressure becomes unnecessary and as compared to SIMPLE, the resulting velocity corrections will satisfy better the momentum equations. Consequently, a higher rate of convergence is obtained. Thus, with the exceptions of dropping $$ {\tilde{\mathbf{H}}}_{C} [{\mathbf{v^{\prime}}} - {\mathbf{v^{\prime}}}_{C} ] $$ rather than $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$ and replacing $$ {\mathbf{D}}_{C}^{{\mathbf{v}}} $$ by $$ {\tilde{\mathbf{D}}}_{C}^{{\mathbf{v}}} $$, the steps involved in the SIMPLEC algorithm are similar to those of the SIMPLE algorithm.

15.7.2 The PRIME Algorithm

In the PRIME (PRessure Implicit Momentum Explicit) [19] algorithm, the momentum equation is solved explicitly. This explicit treatment is justified by the small contribution to the convergence of the entire flow field by the iterative sweeps of the momentum equation. On the other hand, finding the correct solution for the pressure field represents the most important factor in the overall convergence. Based on this argument, the PRIME algorithm can be summarized as follows:

The momentum equation is solved explicitly to obtain a new velocity field v * using

(15.176)

This velocity field is employed to derive the pressure correction equation. Thus defining the correction fields such that

(15.177)

the corrected field would satisfy

(15.178)

leading to the following expression relating velocity and pressure correction:

(15.179)

Substituting Eq. (15.179) and its correction into the continuity equation yields

(15.180)

where the underlined terms in Eqs. (15.179) and (15.180) are neglected.

The terms neglected in PRIME $$ \left( {{\mathbf{H}}_{C} \left[ {{\mathbf{v}}^{*} {-}{\mathbf{v}}^{(n)} } \right] \, + {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}]} \right) $$ can become smaller than the term neglected in SIMPLE $$ \left( {{\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}]} \right) $$ if $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$ and $$ {\mathbf{H}}_{C} \left[ {{\mathbf{v}}^{*} {-}{\mathbf{v}}^{(n)} } \right] $$ are of opposite signs. It is worth noting that $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}\left] { \, = {\mathbf{H}}_{C} } \right[{\mathbf{v}}^{**} {-}{\mathbf{v}}^{*} ] $$ is a correction to satisfy continuity, while $$ {\mathbf{H}}_{C} \left[ {{\mathbf{v}}^{*} {-}{\mathbf{v}}^{(n)} } \right] $$ is a correction to satisfy momentum. Usually the corrector added to satisfy momentum is opposite to that added to satisfy continuity and hence, the neglected term $$ \left( {{\mathbf{H}}_{C} \left[ {{\mathbf{v}}^{*} {-}{\mathbf{v}}^{(n)} } \right] \, + {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}]} \right) $$ is smaller. Moreover, since the momentum equations are explicitly solved, no under-relaxation is required. This has the advantage of increasing the stability of the algorithm.

15.7.3 The PISO Algorithm

In the PISO algorithm [18, 25], the $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$ term is accounted for as part of a correction procedure composed of two or more steps. The first step is similar to the SIMPLE algorithm where $$ \mathbf{v}^{\prime} $$ is computed from Eq. (15.83) while neglecting $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$. The continuity satisfying velocity v ** and pressure p * fields are used to recalculate the coefficients of the momentum equation and then to solve it explicitly. The new velocity field v *** is used to calculate the mass flow rate field $$ \dot{m}^{***} $$ at the element faces using the Rhie-Chow interpolation. Then, $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$ is partially recovered in a second corrector step where the velocity correction is written as

(15.181)

In Eq. (15.181) the underlined term represents the portion of the $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$ that is recovered by the second corrector step. The second velocity correction satisfies

(15.182)

Using Eq. (15.181) with the Rhie-Chow interpolation between points C and F, a new pressure-correction field is obtained as

(15.183)

where the underlined terms in Eqs. (15.182) and (15.183) are again neglected. This corrector step may be repeated as many times as desired, each time recovering a new additional portion of $$ {\mathbf{H}}_{C} [{\mathbf{v^{\prime}}}] $$.

By following the sequence of events, it can be easily seen that PISO may be considered as a combination of one SIMPLE step and one or more PRIME steps, hence combining the implicitness of the SIMPLE algorithm with the stability of the PRIME algorithm. The sequence of events in the collocated PISO algorithm can be summarized as follows:

1.

To compute the solution at time t + Δt, use as an initial guess the solution at time t for pressure, velocity, and mass flow rate fields p (n), u (n), and $$ \dot{m}^{(n)} $$, respectively.

SIMPLE Step

2.

Solve implicitly the momentum equation given by Eq. (15.70) to obtain a new velocity field v *.

3.

Update the mass flow rate at the cell faces using the Rhie-Chow interpolation technique (Eq. 15.100) to obtain a momentum satisfying mass flow rate field $$ \dot{m}_{f}^{*} $$.

4.

Using the new mass flow rates, assemble the pressure correction equation (Eq. 15.98) and solve it to obtain a pressure correction field p′.

5.

Update the pressure and velocity fields at the cell centroids and the mass flow rate at the cell faces to obtain continuity-satisfying fields using Eq. (15.101).

PRIME Step(s)

6.

Using the latest available velocity and pressure fields, calculate the coefficients of the momentum equation and solve it explicitly.

7.

Update the mass flow rate at the cell faces using the Rhie-Chow interpolation technique.

8.

Using the new mass flow rates, assemble the pressure correction equation (Eq. 15.183) and solve it to obtain a pressure correction field.

9.

Update pressure, velocity, and mass flow rate fields using expressions similar to the ones given in Eq. (15.101).

10.

Go to step 6 and repeat based on the desired number of corrector steps.

11.

Set the initial guess for velocity, mass flow rate, and pressure as u **, $$ \dot{m}^{**} $$, and p *.

12.

Go back to step 2 and repeat until convergence.

13.

Set the solution at time t + Δt to be equal to the converged solution and set the current time t + Δt to be t.

14.

Advance to the next time step.

15.

Go back to step 1 and repeat until the last time step is reached.

A flowchart of the PISO algorithm is presented in Fig. 15.27.

Fig. 15.27

A flow chart of the PISO algorithm

15.8 Optimum Under-Relaxation Factor Values for v and $$ p^{\prime} $$

To promote convergence in the SIMPLE algorithm the momentum and continuity equations are under relaxed using the under relaxation factors λ v and λ p , respectively. An important task is to find the under relaxation values that will result in the optimum convergence rate. Recalling that the velocity correction is obtained without any under relaxation from

(15.184)

Moreover, in calculating the pressure field, the pressure correction is under relaxed in order for the velocity correction field given by Eq. (15.184) to satisfy the exact velocity correction equation given by

(15.185)

Equating Eqs. (15.184) and (15.185), an expression for λ p is obtained as

(15.186)

The SIMPLEC algorithm eliminated the need to under relax pressure correction and resulted in the optimum acceleration rate. Therefore, using the approximation introduced in SIMPLEC, the velocity correction at C can be written as the weighted average of the velocity corrections at the neighboring grid points such that

(15.187)

From Eqs. (15.70)–(15.73) the coefficient $$ a_{C}^{{\mathbf{v}}} $$ can be expressed as

(15.188)

which in the limit of a steady state solution (the case for which under relaxation is used, since for an unsteady situation the time step plays the role of the under relaxation factor) reduces to

(15.189)

Substituting Eq. (15.189) in Eq. (15.187), the velocity correction is approximated as

(15.190)

substituting Eq. (15.190) in Eq. (15.186), an expression relating λ v and λ p is obtained as

(15.191)

Experience has shown that the performance of the SIMPLE algorithm with its under relaxation factors satisfying Eq. (15.191) is similar to that of the SIMPLEC algorithm.

15.9 Treatment of Various Terms with the Rhie-Chow Interpolation

15.9.1 Treatment of the Under-Relaxation Term

The use of the collocated grid method with the Rhie-Chow interpolation resulted in solutions that are dependent on the value of under relaxation factor in the momentum equation. To eliminate this dependence, a modification to the Rhie-Chow interpolation is required. The under relaxed momentum equation is written as

(15.192)

where $$ {\mathbf{b}}_{C}^{{\mathbf{v}}} $$ is the source term of the momentum equation from which the pressure and under relaxation source terms are extracted and $$ {\mathbf{v}}_{C}^{(n)} $$ is the previous iteration value of velocity at cell centroid C. The corresponding under relaxed momentum equation using a staggered grid formulation can be expressed as

(15.193)

The Rhie-Chow interpolation method mimics the staggered grid formulation by forming a pseudo-momentum equation at the cell face. It is because of this behavioral imitation that the Rhie-Chow interpolation is successful. Therefore as a guiding principle, the yardstick to any modification to the Rhie-Chow interpolation should be whether the modified formulation is similar to the staggered grid formulation. Therefore, the form of the under relaxed equation using the Rhie-Chow interpolation should be given by

(15.194)

The average of the first term on the right hand side is obtained as

(15.195)

Substituting Eq. (15.195) into Eq. (15.194), the extended Rhie-Chow interpolated cell face velocity $$ {\mathbf{v}}_{f} $$ is obtained as

(15.196)

Not accounting for the effect of under-relaxation on the face velocity results in solutions that depend on the under relaxation factor.

15.9.2 Treatment of the Transient Term

When solving a transient problem with a backward Euler transient scheme the discretized momentum equation can be written as

(15.197)

where $$ {\mathbf{b}}_{C}^{{\mathbf{v}}} $$ is the source term of the momentum equation from which the pressure and transient source terms are extracted. The equivalent equation for the staggered grid variable arrangement has a similar form given by

(15.198)

Using the Rhie-Chow interpolation method, a pseudo cell-face equation will be constructed as

(15.199)

The average of the first term on the right hand side is obtained as

(15.200)

Substituting into Eq. (15.84), the extended Rhie-Chow interpolated cell face velocity $$ {\mathbf{v}}_{f} $$ is obtained

(15.201)

Not accounting for the effect of the unsteady term on the face velocity results in solutions that are time step dependent and have an oscillatory behavior for small time step. This correction is valid only for the first order Euler discretization. In case of more accurate time discretization schemes similar corrections can be performed following the same principles.

15.9.3 Treatment of the Body Force Term

When treating body forces in the staggered grid arrangement, the stencil of the body force term is exactly that of the pressure gradient term. In the case of a collocated grid arrangement, the body force, velocity, and momentum variables are calculated at the same location. Thus, in order to have a discretization of the body force that retains a similar stencil as the pressure, a redistribution of the body force term is needed. The discretized momentum equation is written as

(15.202)

where the double bar indicates two averaging steps. The first step is to compute $$ \overline{{{\mathbf{B}}_{C}^{{\mathbf{v}}} }} $$ (Fig. 15.28) at the cell face as

(15.203)

while the second (Fig. 15.29) is to get an average of these face values at the cell centre.

Fig. 15.28

Treatment of body force and pressure gradient on a staggered grid

Fig. 15.29

Standard and improved Rhie-Chow treatment of body forces

The average values at cell center can best be derived [26] by considering the one dimensional situation depicted in Fig. 15.30.

Fig. 15.30

One dimensional stationary fluid

For the case of a stationary fluid, the pressure gradient should be in equilibrium with the body forces leading to

(15.204)

Expanding the above equation, a relation between the pressures at C and F can be written as

(15.205)

or more generally as

(15.206)

where B f is the magnitude of B f given by

(15.207)

For incompressible flows, the variation with temperature of the density appearing in the body force term is modeled using the Boussinesq approximation as given by Eq. (3.​101).

Again for cell C the pressure gradient should be in equilibrium with the body forces, resulting in

(15.208)

However the pressure gradient for cell C is computed as

(15.209)

substituting from Eq. (15.206) gives

(15.210)

which implies that

(15.211)

The second requirement is that the cell-face velocity be similar to that of the staggered arrangement equation:

(15.212)

where $$ {\mathbf{b}}_{C}^{{\mathbf{v}}} $$ is the source term given in Eq. (15.71) from which the pressure and body force terms are extracted. The averaging of the coefficients yields

(15.213)

and substituting into Eq. (15.179), the extended Rhie-Chow interpolated cell face velocity $$ {\mathbf{v}}_{f} $$ is obtained as

(15.214)

where $$ \overline{{\overline{\overline{{{\mathbf{B}}_{f}^{{\mathbf{v}}} }}} }} $$ is calculated as

(15.215)

The above additional treatment of the cell face velocity increases the overall robustness of the solution procedure for situations where variations in body forces are important (e.g., free-surface flows).

15.9.4 Combined Treatment of Under-Relaxation, Transient, and Body Force Terms

In general all three terms described above should be dealt with together. This necessitates modifying the Rhie-Chow interpolation to account for all three effects. Fortunately this can easily be derived by using the principle of superposition leading to the following interface velocity:

(15.216)

where in calculating $$ \overline{{{\mathbf{D}}_{f}^{{\mathbf{v}}} }} $$ the under relaxed value of the $$ a_{C}^{{\mathbf{v}}} $$ coefficient is used.

15.10 Computational Pointers

15.10.1 uFVM

In uFVM, the pressure correction equation is implemented in one script file denoted by cfdAssembleMdotTerm. Listing 15.1 shows the core of the algorithm whereby the coefficients of the pressure correction equation are assembled by linearizing the fluxes at each of the interior faces. In addition, the mdot field (i.e., the mass flow rate at the faces) is calculated based on Eq. (15.216), which is subdivided into 9 terms (i.e., terms I trough IX) and assembled step by step to produce the cell face velocity. The terms into which the velocity at the face is decomposed are as follows:

Listing 15.1

Script used for the calculation of the mass flow rates and coefficients of the pressure correction equation in uFVM

term I: the interpolated velocity field $$ \overline{{{\mathbf{v}}_{f} }} $$,

terms II and III: the face and average pressure gradients $$ - \overline{{{\mathbf{D}}_{f}^{{\mathbf{v}}} }} \left( {\nabla p_{f} - \overline{{\nabla p_{f} }} } \right) $$,

terms IV and V: the average and redistributed body forces $$ \overline{{{\mathbf{D}}_{f}^{{\mathbf{v}}} }} \left( {\overline{{{\mathbf{B}}_{f}^{{\mathbf{v}}} }} - \overline{{\overline{\overline{{{\mathbf{B}}_{f}^{{\mathbf{v}}} }}} }} } \right) $$,

terms VI and VII: the transient fluxes $$ \frac{{\overline{{a_{f}^{ \circ } {\mathbf{D}}_{f}^{{\mathbf{v}}} }} }}{{V_{f} }}\left( {{\mathbf{v}}_{f}^{ \circ } - \overline{{{\mathbf{v}}_{f}^{ \circ } }} } \right) $$, and

terms VIII and IX: the relaxation correction term $$ (1 - \lambda^{\textbf{v}} )({\mathbf{v}}_{f}^{(n)} - \overline{{{\mathbf{v}}_{f}^{(n)} }} ) $$.

15.10.2 OpenFOAM®

The numerical techniques introduced so far are used in what follows to develop OpenFOAM® [27] applications for solving the incompressible Navier-Stokes equations.

15.10.2.1 Pressure Correction SIMPLE Solvers

Based on the SIMPLE algorithm, a number of solvers will be constructed. The base solver, simpleFoam, will be presented first. This is followed by a number of versions, with each one adding more capabilities to the base code. These solvers can be summarized as follows:

1.

simpleFoam (not the OpenFOAM® built-in solver) is the base code that incorporates the SIMPLE Algorithm in its most basic form.

2.

simpleFoamImproved extends the base code to allow for improved treatment of relaxation.

3.

simpleFoamTransient adds transient capabilities to the steady-state simpleFoam.

4.

simpleFoamBuoyancy adds to the code the body force treatment.

More versions will be covered in the chapters to follow, each one with extended capabilities, added by modifying the base code described in this chapter. A list of the versions that will be covered in the next chapters is given below.

5.

simpleFoamCompressible is the compressible version of simpleFoam (Chap. 16)

6.

simpleFoamTurbulent includes capabilities for treating turbulent flows (Chap. 17).

simpleFoam

Before reviewing the simpleFoam code, some basic notational issues are addressed. The first step is to define, as shown in Listing 15.2, the geometric fields and parameters that will be initialized and used in the code.

Listing 15.2

The #include macro derivatives used to define the types of objects needed

In Listing 15.2, the #include macro directives outside the main function are needed to define the types of objects that are then declared and used in the application. The #include “fvCFD.H” contains a list of definitions for classes that are in general necessary to build any application in OpenFOAM®. In the developed application an additional header, not present in the fvCFD.H header, necessary for the SIMPLE solver implementation will be added.

The use of the #include statements inside the main function is a compacting procedure, with each declared statement representing a piece of the code moved to the corresponding file name. For example, the statement #include “createMesh.H” just represents the code shown in Listing 15.3, which is necessary to instantiate the mesh class.

Listing 15.3

The code representing the #include createMesh.H file necessary to instantiate the mesh class

Once the necessary initialization has been performed, the next step is the definition of the proper fields or variables needed by the solver. These are defined in file “createFields.H”. The first defined field, shown in Listing 15.4, is the pressure field (p).

Listing 15.4

Script used to define the pressure field

Since the solution is obtained by solving a pressure correction equation instead of a pressure equation, a pressure correction field (pp) is also defined (Listing 15.5).

Listing 15.5

Script used to define the pressure correction field

It is worth noting that in Listing 15.5 a different constructor is used to define the pressure correction field. Since the pressure corrector represents the pressure itself, the same boundary conditions defined for the real pressure can be used for the pressure correction field without the need to define the same quantity twice.

The list of pressure boundary types displayed in Listing 15.6 are now copied under the pbt variable in Listing 15.5 and directly used in the constructor of pp.

Listing 15.6

Script showing the declaration of the different pressure boundary types

The corrector should reset to zero the correction field at every iteration and should also apply a zero value at all boundaries for which a Dirichlet boundary condition is used for the pressure.

The velocity and corresponding mass flux fields must also to be defined. As depicted in Listing 15.7, the velocity field is defined through an input file while the mass flux field can be defined as a derived quantity.

Listing 15.7

Script used to define the velocity and mass flux fields

Finally the fluid thermo-physical properties should also be defined. For incompressible laminar flows this involves simply assigning a value to the kinematic viscosity nu, as shown in Listing 15.8.

Listing 15.8

Code used to define the fluid thermo-physical properties

After defining all variables the implementation of the SIMPLE algorithm can proceed. A while loop can be used for the cases when the stopping criterion is the number of SIMPLE iterations. For each single loop, the momentum and pressure correction equations are solved and updates of the variables are performed. Starting with the momentum equation written as (the form solved in OpenFOAM®),

(15.217)

where the kinematic viscosity v is defined as

(15.218)

and p represents the pressure divided by the density, i.e.,

(15.219)

its solution is translated into the script shown in Listing 15.9.

Listing 15.9

Script to solve the momentum equation

The first instruction in Listing 15.9 defines the finite volume discretization of the momentum equation in vector form with its storage matrix (the three components of the velocity vector are solved in a segregated manner despite its vectorial implementation). The system is then implicitly relaxed and solved via an iterative solver.

Once the momentum equation is solved, a new guess for the velocity field is obtained. This velocity does not satisfy the continuity equation in general and the assembly of the continuity equation in the form of a pressure correction equation is now required to correct the flow field. The pressure correction equation is written as

(15.220)

where a component of $$ {\bar{\mathbf{D}}}$$ at an element centroid is computed as

(15.221)

with values at the faces obtained by interpolation. Its implementation is translated into the following syntax (Listing 15.10):

where div(mDot) is basically $$ \sum {\dot{m}_{f} } $$, while pp represents p′ and is reset to zero at each iteration. Moreover, the DUf variable is the value of D at the cell face obtained, as shown in Listing 15.11, by linear interpolation using the values at the nodes straddling the face. Further, .A() represents the diagonal terms in the momentum matrix divided by the volume.

Listing 15.10

Script to implement the pressure correction equation

Listing 15.11

Script to calculate the values of DUf

Listing 15.12 computes the mass flow rate at cell faces (mDot) using the Rhie-Chow interpolation where the calculation of ∇p f and $$ \overline{{\nabla p_{f} }} $$ is clearly shown.

Listing 15.12

Script to compute the mass flow rate at cell faces using the Rhie-Chow interpolation

The pressure correction equation is now fully set and is solved by executing the statement in Listing 15.13.

Listing 15.13

Statement used to solve the pressure correction equation

Once the pressure correction equation is solved, the velocity, pressure, and mass flow rate fields are updated using the obtained pressure correction field. Starting with the mass flow rate field (i.e., the mDot flux), it is updated by executing the below statement (Listing 15.14).

Listing 15.14

Statement used to update the mass flow rate field to satisfy continuity

The flux() function in Listing 15.14 provides the matrix multiplication, the extra diagonal matrix coefficients, and the corresponding solution. Recalling the finite volume discretization of the diffusion term, each extra diagonal of coefficients represents a face of the mesh. Thus the update of the fluxes can be performed in a more consistent way using directly the matrix coefficients and cell values. A simplified version of the flux() function is shown in Listing 15.15.

Listing 15.15

A simplified version of the flux() function where the flux correction mDotPrime is computed

In Listing 15.15 the correction flux mDotPrime (Eq. 15.101) is basically evaluated by performing a loop over the faces using the upper and lower coefficients of the matrix and multiplying these coefficients with the corresponding cell values.

Finally the velocity and pressure at cell centroids are updated using the script shown in Listing 15.16,

Listing 15.16

Update of the velocity and pressure fields at cell centroids

where the variable URF is the explicit relaxation factor for pressure update λ p , necessary for a stable SIMPLE solver.

simpleFoamImproved

In simpleFoamImproved the Rhie-Chow interpolation is extended to account for the relaxation of the velocity field. This is translated into the syntax presented below in Listing 15.17 that expands the generic Rhie-Chow interpolation to include the additional term in Eq. (15.196).

Listing 15.17

Improved Rhie-Chow interpolation accounting for under relaxation

Thus the fields mdotf.prevIter() and U.prevIter() need to be defined.

simpleFoamTransient

In simpleFoamTransient the Rhie-Chow interpolation is extended to account for the transient term. Thus the expression for the mass flow rate becomes (Listing 15.18).

Listing 15.18

Rhie-Chow interpolation accounting for the effects of under-relaxation and the unsteady term

Furthermore the main loop is modified to add a transient loop, with the main code becoming as shown in Listing 15.19.

Listing 15.19

The main loop used for solving unsteady flow problems

simpleFoamBuoyancy

The simpleFoamBuoyancy solver adds to simpleFoamTransient the following capabilities: (i) the solution of the energy equation, (ii) the inclusion of a body source term in the momentum equation, and (iii) an account of the effects of the body force term redistribution in the Rhie-Chow interpolation.

The codes used to introduce these modifications are shown in Listings (15.20), (15.21), and (15.22).

Listing 15.20

The script used to solve the energy equation

The code needed to solve the energy equation is given in Listing (15.20).

The source term in the momentum equation is implemented as (Listing 15.21),

Listing 15.21

Accounting for the body force term source in the momentum equation

while the calculation of the mass fluxes using the Rhie-Chow interpolation are as displayed in Listing (15.22).

Listing 15.22

The modified Rhie-Chow interpolation accounting for body forces

15.11 Closure

This chapter presented the segregated pressure-based approach for solving incompressible flow problems on collocated grids. It also demonstrated that the success of the Rhie-Chow interpolation on collocated grids is due to its formation of a pseudo-momentum equation at the cell face that has a tight pressure gradient stencil similar to the one resulting from a staggered grid formulation. In addition, the details of implementing the most commonly encountered boundary conditions in the momentum and pressure-correction equations were discussed. The next chapter will extend the pressure based method to predict compressible fluid flow at all speeds.

15.12 Exercises

Exercise 1

A portion of a water-supply system is shown in Fig. 15.31. The flow rate $$ \dot{m} $$ in a pipe section is given by

where Δp is the pressure drop over the length of the pipe section, and C is the hydraulic conductance. The following data is known:

Find p ₃, p ₄, p ₅, $$ \dot{m}_{A} ,\dot{m}_{B} ,\dot{m}_{C} ,\dot{m}_{D} $$ and $$ \dot{m}_{E} $$ using the following procedure

Start with a guess for p ₃, p ₄, and p ₅.

Compute $$ \dot{m}^{*} $$ values based on the guessed pressures.

Construct the pressure-correction equations and solve for $$ p^{\prime}_{3} $$, $$ p^{\prime}_{4} $$ and $$ p^{\prime}_{5} $$.

Update the pressures and the $$ \dot{m}^{*} $$ values

Do you need to iterate? Why?

Fig. 15.31

A portion of a water-supply system

Exercise 2

A one dimensional flow through a porous material is governed by

where c is a constant. The continuity equation is

Use the SIMPLE procedure for the grid shown in Fig. 15.32 to compute p ₂, u A , and u B from the following data:

with the size and area at the center of each control volume given by

Fig. 15.32

One dimensional flow in a porous material

Exercise 3

In the Steady, one dimensional, constant density situation shown in Fig. 15.33, the velocity u is calculated at locations B and C, while the pressure is calculated at locations 1 and 2. The velocity correction formulae are written as

where the values of D B and D C are 3 and 4, respectively. The boundary conditions are u A  = 5 and p ₃ = 70.

(a)

If at a given stage in the iteration process, the momentum equations give $$ u_{B}^{*} = 4 $$ and $$ u_{C}^{*} = 6 $$, calculate the values of p ₁ and p ₂.

(b)

Explain how you could obtain the values of p ₁ and p ₃ if the right hand boundary condition is given as u C  = 5 instead of p ₃ = 70.

Fig. 15.33

Incompressible flow in a one dimensional domain

Exercise 4

Consider the main control volume shown in Fig. 15.34. A staggered mesh is used with the u and v velocity components stored as shown. The following quantities are given: u w  = 7, v s  = 3, p N  = 0 and p E  = 50. The flow is steady and the density is constant. The momentum equations for u e and v n are given by:

Fig. 15.34

A main control volume in a two-dimensional staggered grid arrangement

Also given D e  = 2, D n  = 1.6, and the control volume has Δx = Δy = 1.

(a)

Starting with a guessed value of $$ p_{C}^{(n)} = 50 $$, use the SIMPLE algorithm to find u e and v n .

(b)

Is an iteration loop needed for this problem? Explain.

Exercise 5

Consider the simplified one-dimensional Forchheimer model for flow in porous media given by

with the continuity equation given by

In the above equations b is a constant and ε is the porosity coefficient that accounts for the effective porous area.

Devise a SIMPLE-like procedure to compute p C , u e , and u w for the following data:

Start with the following initial values for velocity and pressure (Fig. 15.35):

Fig. 15.35

One-dimensional Forchheimer model for flow in porous media

Exercise 6

Compute the interface velocities u e and u w using the Rhie-Chow interpolation and compare it to the averaged values $$ \bar{u}_{e} $$ and $$ \bar{u}_{w} $$ knowing the following data (Fig. 15.36):

Fig. 15.36

A one dimensional collocated grid

Exercise 7

In OpenFOAM® develop a SIMPLEC pressure correction algorithm by modifying the SIMPLE algorithm described in this chapter. Hint: in order to find the summation of the extra diagonal coefficients use the H1() function of the fvMatrix.

Exercise 8

Check the pisoFoam solver located in $FOAM_SRC/../applications/solvers/incompressible/pisoFoam/pisoFoam.C and compare it with the algorithm described in this chapter, i.e., “The Collocated PISO Algorithm”. Find out the inconsistency with the standard OpenFOAM® implementation.

Exercise 9

Develop a pressure correction PISO algorithm for OpenFOAM®.

References

1.

Patankar SV (1981) A calculation procedure for two dimensional elliptic situations. Numer Heat Transfer 4(4):409–425CrossRef

2.

Patankar SV (1980) Numerical heat transfer and fluid flow. Hemisphere, NY

3.

Patankar SV, Spalding DB (1972) A calculation procedure for heat, mass and momentum transfer in three-dimensional parabolic flows. Int J Heat Mass Transf 15(10):1787–1806MATHCrossRef

4.

Harlow FH, Welch JE (1965) Numerical calculation of time-dependent viscous incompressible flow of fluid with free surface. Phys Fluids 8(12):2182–2189MATHCrossRef

5.

Van Doormaal JP, Raithby GD (1985) An evaluation of the segregated approach for predicting incompressible fluid flows. ASME Paper 85-HT-9, Presented at the national heat transfer conference, Denver, Colorado

6.

Raithby GD, Schneider GE (1979) Numerical solution of problems in incompressible fluid flow: treatment of the velocity-pressure coupling. Numer Heat Transfer, Part A 2(4):417–440

7.

Patankar SV (1975) Numerical prediction of three-dimensional flow. In Launder BE (ed) studies in convection: theory, measurement, and application, vol 1. Academic, New York, pp 1–9

8.

Rhie CM, Chow WL (1983) Numerical study of the turbulent flow past an airfoil with trailing edge separation. AIAA J 21:1525–1532MATHCrossRef

9.

Rhie CM (1988) A three-dimensional passage flow analysis method aimed at centrifugal impellers. Comput Fluids 13:443–460CrossRef

10.

Majumdar S (1988) Role of under relaxation in momentum interpolation for calculation of flow with nonstaggered grids. Numer Heat Transfer 13:125–132CrossRef

11.

Miller TF, Schmidt FW (1988) Use of a pressure-weighted interpolation method for the solution of incompressible Navier-Stokes equations on a nonstaggered grid system. Numer Heat Transfer 14:213–233MATHCrossRef

12.

Karki KC, Patankar SV (1988) Calculation procedure for viscous incompressible flows in complex geometries. Numer Heat Transfer 14:295–307MATH

13.

Choi SK, Nam HY, Cho M (1993) Use of the momentum interpolation method for numerical solution of incompressible flows in complex geometries: choosing cell face velocities. Numer Heat Transfer, Part B 23:21–41CrossRef

14.

Choi SK, Nam HY, Lee YB, Cho M (1993) An efficient three-dimensional calculation procedure for incompressible flows in complex geometries. Numer Heat Transfer, Part B 23:387–400CrossRef

15.

Choi SK, Nam HY, Cho M (1994) Use of staggered and nonstaggered grid arrangements for incompressible flow calculations on nonorthogonal grids. Numer Heat Transfer, Part B 25(2):193–204CrossRef

16.

Choi SK, Nam HY, Cho M (1994) Systematic comparison of finite-volume calculation methods with staggered and nonstaggered grid arrangements. Numer Heat Transfer, Part B 25(2):205–221CrossRef

17.

Van Doormaal JP, Raithby GD (1984) Enhancement of the SIMPLE method for predicting incompressible fluid flows. Numer Heat Transfer 7:147–163MATH

18.

Issa RI (1982) Solution of the implicit discretized fluid flow equations by operator splitting. Mechanical Engineering Report, FS/82/15, Imperial College, London

19.

Maliska CR, Raithby GD (1983) Calculating 3-D fluid flows using non-orthogonal grid. In: Proceedings of the third international conference on numerical methods in laminar and turbulent flows, Seattle, pp 656–666

20.

Acharya S, Moukalled F (1989) Improvements to incompressible flow calculation on a non-staggered curvilinear grid. Numer Heat Transfer, Part B 15:131–152MATHCrossRef

21.

Spalding DB (1980) Mathematical modelling of fluid mechanics, heat transfer and mass transfer processes. Mechanical Engineering Department Report HTS/80/1, Imperial College of Science, Technology and Medicine, London

22.

Moukalled F, Darwish M (2000) A unified formulation of the segregated class of algorithms for fluid flow at all speeds. Numer Heat Transfer, Part B 37:103–139CrossRef

23.

Darwish M, Asmar D, Moukalled F (2004) A comparative assessment within a multigrid environment of segregated pressure-based algorithms for fluid flow at all speeds. Numer Heat Transfer, Part B 45(1):49–74CrossRef

24.

Jang DS, Jetli R, Acharya S (1986) Comparison of the PISO, SIMPLER and SIMPLEC algorithms for the treatment of the pressure-velocity coupling in steady flow problems. Numer Heat Transfer 10:209–228MATHCrossRef

25.

Yen RH, Liu CH (1993) Enhancement of the SIMPLE algorithm by an additional explicit corrector step. Numer Heat Transfer, Part B 24:127–141CrossRef

26.

Mecinger J (2012) An alternative finite volume discretization of body force field on collocated grids. In: Petrova R (ed) Finite volume method-powerful means of engineering design. ISBN:978-953-51-0445-2

27.

OpenFOAM, 2015 Version 2.3.x. http://​www.​openfoam.​org

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_16

16. Fluid Flow Computation: Compressible Flows

F. Moukalled1   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

M. Darwish

Email: darwish@aub.edu.lb

Abstract

The previous chapter presented the methodology for solving incompressible flow problem using pressure based algorithms. In this chapter these algorithms are extended to allow for the simulation of compressible flows in the various Mach number regimes, i.e., over the entire spectrum from subsonic to hypersonic speeds. While incompressible flow solutions do not generally require solving the energy equation, compressibility effects couple hydrodynamics and thermodynamics necessitating the simultaneous solution of the continuity, momentum, and energy equations. The dependence of density on pressure and temperature, a relation expressed via an equation of state, further complicates the velocity-pressure coupling present in incompressible flows. The derivation of the pressure correction equation now involves a density correction that introduces to the equation a convection-like term, in addition to the diffusion-like term introduced by the velocity correction. Another difficulty is introduced by the complex boundary conditions that arise in compressible flow problems. Details on resolving all these issues are presented throughout this chapter.

16.1 Historical

Computational Fluid Dynamics methods have been traditionally classified into two families denoted by density-based and pressure-based. Specifically density-based methods have historically dominated the simulation of transonic and supersonic flows usually encountered in the aeronautics industry, and were well-established when the SIMPLE algorithm was first instigated. SIMPLE, a pressure-based method, was initially developed to address this shortcoming and was quite efficient in resolving incompressible and low Mach number flows.

Early on, efforts were directed towards extending the operation of each of these approaches to flow regimes customarily dominated by the other. Harlow and Amsden [1, 2] were amongst the earliest to simulate fluid flow at all speeds. In their work, the use of pressure as a main variable in preference to density was presented an advantage since its variations remained finite irrespective of the Mach number value. Nonetheless it was the work of Patankar [3] that provided a clear resolution to this problem, and allowed for SIMPLE-based methods to genuinely develop into methods capable of resolving fluid flow at all speeds [4–13]. The critical development was the reformulation of the pressure equation to include density and velocity correction such that the type of the equation changed from purely elliptic for incompressible flows to hyperbolic in transonic and supersonic compressible flows [14, 15]. This allowed the SIMPLE-family of methods to seamlessly solve flow problems across the entire Mach number spectrum, with pressure playing the dual role of affecting density in the limit of high Mach compressible flow and velocity in the limit of incompressible flow [16], in order to enforce mass conservation.

16.2 Introduction

An important advantage of the pressure-based approach is its ability to resolve fluid flows in the various Mach number regimes without any artificial treatment to promote convergence and stabilize computations. This ability of the pressure based method is due to the dual role the pressure plays in compressible flows [17], which can best be described by considering the following two extreme cases:

1.

At very low Mach numbers, the pressure gradient needed to establish the flow field through momentum conservation is so small that it does not significantly influence the density, and the flow can be considered to be incompressible. Hence, density and pressure in addition to density and velocity are very weakly related indicating that variations in density are not sensitive to variations in velocity. In this case the continuity equation can no longer be considered as an equation for density, rather, it acts as a constraint on the velocity field.

2.

At hypersonic speeds, changes in velocity become relatively small as compared to the magnitude of the velocity indicating that variations in pressure do significantly affect density. Consequently, the pressure now acts on density alone through the equation of state to satisfy mass conservation [16, 18] and the continuity equation can be viewed as the equation for density.

The above limiting cases highlight the dual role played by pressure in compressible flow situations. It clearly shows that pressure acts on both the density field through the equation of state and the velocity field via the gradient in the momentum equation to enforce mass conservation. This dual role explains the success of the pressure-based approach to predict fluid flow at all speeds. This fact however did not deter workers in the density based track from using the artificial compressibility technique [19] to develop methods capable of solving fluid flow at all speeds. To overcome degradation in performance due to the stiff matrices encountered in these methods, preconditioning of the resulting stiff matrices was introduced and several methods [20, 21] using this technique have recently appeared in the literature.

Similarly several pressure-based methods [22] for predicting fluid flow at all speeds following either a staggered grid approach [23] or a collocated variable formulation have been developed. While in some methods primitive variables were used, others employed the momentum components as dependent variables. Some workers adopted the stream-wise directed density-retardation concept, which is controlled by Mach-number-dependent monitor functions [24, 25], to account for the hyperbolic character of the conservation laws in the transonic and supersonic regimes. Other techniques used the first order upwind scheme for evaluating the density at the control volume faces at high Mach number values and the central difference scheme at low values [26].

This chapter extends the collocated pressure-based technique developed in the previous chapter allowing the simulation of fluid flows at all Mach number values. The adopted method is easy to implement, highly accurate, and does not require any explicit addition of damping terms to improve robustness or to properly resolve shock waves.

16.3 The Conservation Equations

The conservation equations for solving compressible flow problems include the continuity, momentum, and energy equations. For a Newtonian fluid behaving as an ideal gas, these equations can be expressed as

(16.1)

(16.2)

(16.3)

where the form of the energy equation adopted here is the one expressed in terms of temperature. The above set of equations should be appended by an equation of state relating density to pressure and temperature, i.e., $$ \rho = \rho \left( {p,T} \right) $$, which for an ideal gas is given by

(16.4)

where R is the gas constant.

In the derivations to follow, superscript n refers to values used at the beginning of an iteration, superscript $$ ^{*} $$ indicates values updated once during an iteration, and superscript $$ ^{**} $$ refers to values updated twice during the same iteration.

16.4 Discretization of the Momentum Equation

The discretized momentum equation, Eq. (16.2), over the control volume C shown in Fig. 16.1 is similar to its incompressible form given in Chap. 15. The only two differences are related to the interpolation of density to the interface and the additional term $$ - \left( {2/3} \right)\nabla \left( {\mu \nabla \cdot {\mathbf{v}}} \right) $$ involving the bulk viscosity. Starting with the first difference, the density in compressible flows is no longer constant and since it is stored at the control volume centroids it has to be interpolated to find its value at the control volume faces where it is needed for computing the mass flow rate. The use of a linear interpolation profile (central difference) causes oscillation at high speeds. Thus a bounded upwind biased scheme should be used. Any of the bounded convective schemes presented in Chaps. 11 and 12 can be adopted for that purpose.

Fig. 16.1

A schematic of a control volume $$ C $$ with its neighbors

The second difference is the additional term involving $$ \nabla \left( {\mu \nabla \cdot {\mathbf{v}}} \right) $$. This term has not been discretized so far and its discretized form is obtained by making use of Eq. (2.​85) based on which the volume integral of the gradient of a scalar quantity is transformed into a surface integral and then into a summation of fluxes over the faces of the control volume according to

(16.5)

The divergence of the velocity vector at the faces is computed as

(16.6)

where the gradient of $$ \phi = u,v $$ or w is interpolated linearly to the face

(16.7)

The final discretized form of the momentum equation is given by Eq. (15.​70) with its coefficients given by Eq. (15.​71) with the term $$ - \left( {2/3} \right)\mathop \sum \limits_{f{\sim}nb\left( C \right)} \left( {\mu \nabla \cdot {\mathbf{v}}} \right)_{f} {\mathbf{S}}_{f} $$ added to the source term in that equation.

As for incompressible flow problems, the algebraic equations are under relaxed and written in the form of Eq. (15.​78), which is suitable for the derivation of the pressure correction equation.

16.5 The Pressure Correction Equation

The pressure correction equation for compressible flows is obtained by a simple extension of that for incompressible flows. The difference is related to variations in density which are accounted for by defining a density correction field $$ \rho^{\prime} $$ and relating it to the pressure-correction field through a pressure-density relation. This, however, yields substantial differences in the treatment of boundary conditions, as will be explained later in the chapter.

For an ideal gas the relation between pressure and density is written as

(16.8)

Using this relation, an equation relating density correction to pressure correction can be derived by expanding Eq. (16.8) via a Taylor series to yield

(16.9)

The corrected pressure, density, velocity, and mass flow rate fields are defined as

(16.10)

and the semi-discretized continuity equation can be written in terms of the correction fields as

(16.11)

where

(16.12)

The second order correction term $$ \rho_{f}^{\prime} {\mathbf{v}}_{f}^{\prime} \cdot {\mathbf{S}}_{f} $$ is usually neglected because it is considerably smaller than other terms. This approximation does not influence the convergence rate except during the first few iterations of the solution process. In addition, the final solution is not affected, since at the state of convergence, the correction fields vanish.

Using the Rhie-Chow interpolation for $$ {\mathbf{v}}_{f}^{*} $$ and $$ {\mathbf{v}}_{f}^{\prime} ,\dot{m}_{f}^{*} $$ and $$ \dot{m}_{f}^{\prime} $$ are respectively expressed as

(16.13)

and

(16.14)

where the second order term is neglected. Note the substitution of $$ \rho_{f}^{\prime} $$ with $$ C_{\rho,\,f} p_{f}^{\prime} $$.

The underlined term in Eq. (16.14) presents the same difficulties as for the incompressible algorithm and is usually dropped from the equation. Neglecting this term, the correction to the mass flow rate becomes

(16.15)

where the first term on the right hand side of Eq. (16.15) is similar to that arising in incompressible flow while the second term is the new density correction contribution. This second term is important as it transforms the pressure correction equation from an elliptic equation to a hyperbolic one capable of resolving shock waves that may arise at supersonic and hypersonic speeds. This allows the compressible SIMPLE algorithm to be used for predicting fluid flow at all speeds without the need for any special preconditioning.

More insight can be gained through a simple normalization procedure whereby Eq. (16.15) is divided by $$ \left( {\dot{m}_{f}^{ * } \cdot {\mathbf{S}}_{f} } \right){{C_{p,f} } \mathord{\left/ {\vphantom {{C_{p,f} } {\rho_{f}^{ * } }}} \right. \kern-0pt} {\rho_{f}^{ * } }} $$ yielding a weighting factor of 1 for the $$ p_{f}^{\prime } $$ term, and a weighting factor proportional to $$ {1 \mathord{\left/ {\vphantom {1 {\left( {M^{2} } \right)}}} \right. \kern-0pt} {\left( {M^{2} } \right)}} $$ (where M is the Mach number of the flow) for the $$ \nabla p_{f}^{\prime } $$ term, i.e.,

(16.16)

For flows at low Mach number values, the $$ \nabla p^{\prime} $$ correction term dominates returning the equation to an elliptic form as in the incompressible case. On the other hand, for flows at very high Mach number values the $$ p_{f}^{\prime} $$ correction term can no longer be neglected giving a hyperbolic character to the correction equation. This combined behavior allows the prediction of fluid flow at all speeds.

Substitution of Eq. (16.14) in the continuity equation, Eq. (16.11), yields the compressible form of the pressure correction equation and is written as

(16.17)

Again the treatment of the underlined term yields the different variants of the SIMPLE family of algorithms. Dropping the underlined term, the pressure correction equation for the SIMPLE algorithm is obtained as

(16.18)

Equation (16.18) can be obtained directly by substituting Eq. (16.15) in Eq. (16.11).

It is worth stressing that the convection-like term came about naturally during the derivation of the pressure correction equation and its presence is critical for the ability of the algorithm to resolve flows at all speeds. Moreover, for flows at high Mach number values, density correction is convected (i.e., exhibiting a hyperbolic behavior) and the mathematical operator describing this phenomenon is the first order divergence operator. Thus, contrary to incompressible flows where only the diffusion-like term is present implying that the pressure correction equation exhibits an elliptic behavior, pressure correction solutions of the form $$ p^{\prime} + C $$ can no longer satisfy the equation. This indicates that while for incompressible flows any pressure value can be set as a boundary condition without affecting the solution, for compressible flows it is important to define the exact value of pressure at the boundaries because the chosen value will affect the final solution.

It should also be noted that because at convergence the correction field is zero, the order of the scheme used to discretize the convection-like term is of no consequence on the accuracy of the final results. However, this is not the case for $$ \dot{m}_{f}^{*} $$ where the use of high order schemes in its evaluation does improve the shock capturing properties of the algorithm. Thus, to enhance robustness, it is helpful to use an upwind scheme for the discretization of the convection like term. Further, neglecting the non-orthogonal contribution of the diffusion-like term as explained in Chap. 15, the pressure correction equation and its coefficients become

(16.19)

Following the calculation of the pressure-correction field p′ by solving Eq. (16.19) the velocity, pressure, density, and mass flow rate fields are corrected using the following equations:

(16.20)

(16.21)

(16.22)

(16.23)

where $$ \lambda^{\rho } $$ is the under relaxation factor for density.

16.6 Discretization of The Energy Equation

The discretization of the unsteady, convection, and diffusion terms of the energy equation, Eq. (16.3), follows the general procedures described in previous chapters and will not be repeated.

16.6.1 Discretization of the Extra Terms

The focus here will be on the discretization over the control volume C shown in Fig. (16.1), of the new terms appearing on the right hand side of Eq. (16.3). These are specific to the energy equation and have not been handled during the discretization of the general scalar equation. Many of the terms are treated as source terms and evaluated at the centroid of the element during their integration to ensure a second order accurate discretization.

16.6.1.1 The Specific Heat Term

The discretization of the term involving the specific heat proceeds as follows:

(16.24)

16.6.1.2 The Substantial Derivative Term

The discretization of the substantial derivative of the pressure term is performed as

(16.25)

16.6.1.3 The Dissipation Term

The discretized form of the dissipation term involving the bulk viscosity is obtained as

(16.26)

16.6.1.4 The Viscous Dissipation Term

The discretization of the viscous dissipation term is performed in a way similar to the term involving the bulk viscosity and is given by

(16.27)

16.6.1.5 The Source/Sink Term

The term involving the heat source/sink per unit volume is discretized as

(16.28)

The discrete forms of the above terms are substituted into the energy equation to yield the algebraic form of the energy equation as described next.

16.6.2 The Algebraic Form of the Energy Equation

Assuming a first order Euler scheme for the discretization of the unsteady term and a high resolution scheme for the discretization of the convection term applied in the context of a deferred correction approach, the final algebraic form of the energy equation can be written as

(16.29)

where the coefficients are given by

(16.30)

Similar to other variables, under relaxation of the energy equation is usually required.

16.7 The Compressible SIMPLE Algorithm

The various elements of the collocated compressible SIMPLE algorithm are displayed in Fig. 16.2 and can be summarized as follows:

Fig. 16.2

A flow chart of the SIMPLE algorithm for compressible fluid flow

1.

To compute the solution at time $$ t +\Delta t $$, start with the solution at time t for pressure, velocity, density, temperature, and mass flow rate fields $$ p^{\left( n \right)} ,{\mathbf{v}}^{\left( n \right)} ,\rho^{\left( n \right)} ,T^{\left( n \right)} $$, and $$ \dot{m}^{\left( n \right)} $$, respectively, as the initial guess.

2.

Solve the momentum equation given by Eq. (16.2) to obtain a new velocity field $$ {\mathbf{v}}^{*} $$.

3.

Use the equation of state to calculate a new density field $$ \rho^{*} $$.

4.

Update the mass flow rate at the control volume faces using the Rhie-Chow interpolation technique (Eq. 16.13) to obtain a momentum satisfying mass flow rate field $$ \dot{m}^{*} $$.

5.

Using the new mass flow rates calculate the coefficients of the pressure correction equation and solve it (Eq. 16.19) to obtain a pressure correction field $$ p^{\prime} $$.

6.

Update the pressure, density, and velocity fields at the control volume centroids and the mass flow rate at the control volume faces to obtain continuity-satisfying fields using Eqs. (16.20)–(16.23).

7.

Solve the energy equation to obtain a new temperature field $$ T^{*} $$.

8.

Set $$ {\mathbf{v}}^{**} ,\dot{m}^{**} ,\rho^{**} ,T^{*} $$, and $$ p^{*} $$ as the initial guess for velocity, mass flow rate, density, temperature, and pressure.

9.

Go back to step 2 and repeat until convergence.

10.

Set the solution at time $$ t +\Delta t $$ to be equal to the converged solution.

11.

Advance to the next time step by setting the current time t to $$ t +\Delta t $$.

12.

Go to step 1 and repeat until the last time step is reached.

16.8 Boundary Conditions

Generally, there is no difference in the implementation of boundary conditions for the momentum equation between incompressible and compressible flow. Therefore the required modifications in the momentum equation are those discussed in Chap. 15 and will not be repeated here. However substantial differences do arise with the pressure correction equation and will form the main subject of this section. The boundary conditions for the energy equation follow the ones described for a general scalar variable $$ \phi $$ and also will not be repeated here (inlet, outlet, Dirichlet, Van-Neumann, and symmetry conditions).

For a boundary cell, such as the one shown in Fig. 16.3, the continuity equation is written as

(16.31)

where the contribution of the boundary face is separately displayed with $$ \dot{m}_{b}^{*} $$ representing the boundary mass flux and $$ \dot{m}_{b}^{\prime} $$ its correction. Moreover, expressing the Rhie-Chow interpolation at the boundary faces by adopting the same approach that was used for incompressible flow, the velocity, mass flow rate, and mass flow rate correction at a boundary face are expressed as

(16.32)

(16.33)

(16.34)

Fig. 16.3

A boundary control volume

The only difference between these expressions and those presented in Chap. 15 is in the correction equation of the mass flow rate, which has an additional term related to density correction. Moreover, there is no difference in the implementation of boundary conditions at a wall and a symmetry plane between incompressible and compressible flows. Therefore the modifications to the boundary elements presented in the previous chapter for wall and symmetry boundary conditions in the pressure correction equation are applicable here with no need to be repeated.

The boundary conditions left to be discussed here are those applicable at the inlet and outlet. For compressible flow, the conditions to be imposed are dictated by the Mach number values. For an inviscid flow, the mathematical type of the equations changes from elliptic to hyperbolic as the flow changes from subsonic to supersonic. Details regarding their implementation are given next.

16.8.1 Inlet Boundary Conditions

At the inlet to a domain the flow may be subsonic or supersonic necessitating different treatment since the flow equations may be either of the elliptic or the hyperbolic type.

16.8.1.1 Subsonic Flow at Inlet

At subsonic speeds several conditions at inlet to a domain can be imposed. This include specified velocity, specified static pressure and velocity direction, or specified stagnation pressure and velocity direction. The last type should be used when transition to supersonic speed occurs within the domain.

Unlike incompressible flow, since for compressible flow the density depends on pressure, the mass flux remains unknown even with a specified velocity at inlet $$ \left( {{\text{i}}.{\text{e,}}\;\dot{m}_{b}^{\prime} = \rho_{b}^{\prime} {\mathbf{v}}_{b}^{*} \cdot {\textbf{S}}_{b} \ne 0} \right) $$. At an inlet boundary the coefficient multiplying the pressure correction $$ p_{b}^{\prime} $$ is given by

(16.35)

For implementation in the pressure correction equation, $$ p_{b}^{\prime} $$ is expressed in terms of internal nodes and the coefficients at these nodes modified accordingly. For the constant profile case (i.e., $$ p_{b} = p_{C} $$), the $$ a_{C} $$ coefficient is obtained as

(16.36)

The value of the pressure $$ p_{b} $$ is again obtained by extrapolation from the interior as explained in the incompressible flow chapter.

In the case of a specified static pressure at inlet, p b is known and thus $$ p_{b}^{\prime} $$ is set to zero and consequently $$ \rho_{b}^{\prime} $$ is also zero. Therefore the implementation is similar to the incompressible case with the inlet treated as a Dirichlet boundary condition. Knowing the velocity direction, its magnitude is computed as in the incompressible case using Eq. (16.33) leading to an equation similar to Eq. (15.​137). The coefficient of the pressure-correction equation becomes

(16.37)

Specified Total Pressure and Velocity Direction $$(p_{{o,{\kern 1pt} b}} = p_{{o,{\kern 1pt} {\it specified}}} ;\, {\mathbf{e}}_{{\mathbf{v}}} \,{\it specified};\, \dot{m}_{b} = ?;\,{\mathbf{v}}_{b} = ?) $$

For this case, the magnitude of the velocity and the pressure at the boundary are unknown while related through the total pressure equation given by

(16.38)

where b refers to the boundary, $$ p_{o,\,b} $$ is the total pressure, $$ p_{b} $$ the static pressure, $$ \gamma $$ the ratio of specific heats, and $$ M_{b} $$ the Mach number which is equivalent to

(16.39)

Equation (16.37) can be rearranged to give the static pressure in terms of the total pressure as

(16.40)

where $$ {\mathbf{e}}_{{\mathbf{v}}} $$ is the unit vector in the direction of the velocity vector. Differentiating Eq. (16.40) with respect to $$ \dot{m}_{b}^{*} $$ gives

(16.41)

Substituting Eq. (16.41) into Eq. (15.​163) an equation for pressure correction function of the mass flux correction is obtained as

(16.42)

Replacing $$ p_{b}^{\prime} $$ in Eq. (16.34) by its equivalent expression given by Eq. (16.42), the mass flux correction becomes

(16.43)

The modified boundary cell coefficient is obtained by substituting $$ \dot{m}_{b}^{\prime} $$ from Eq. (16.43) in the expanded continuity equation and is given by

(16.44)

It should be mentioned that the boundary condition for the energy equation at a subsonic inlet is usually either a specified static temperature $$ T_{b} $$ or a specified stagnation temperature $$ T_{o,b} $$. If the static temperature is specified, then this is similar to a Dirichlet condition. If the stagnation temperature is specified then at each iteration the value of the static temperature is extracted from the stagnation temperature equation using

(16.45)

and the obtained value treated as known. Thus a Dirichlet-type boundary condition is also applied.

16.8.1.2 Supersonic Flow at Inlet

Specified static pressure, velocity, and temperature

At a supersonic inlet, values for all variables must be specified (pressure, velocity, and temperature). This is equivalent to a Dirichlet-type condition implying that $$ \dot{m}_{b}^{\prime} = p_{b}^{\prime} = 0 $$. Therefore the $$ a_{C}^{{p^{\prime}}} $$ coefficient of the boundary cell is found to be

(16.46)

16.8.2 Outlet Boundary Conditions

16.8.2.1 Subsonic Flow at Outlet

At a subsonic outlet, the pressure is usually prescribed. Therefore the pressure correction $$ p_{b}^{\prime} $$ is set to zero while the mass flow rate correction $$ \dot{m}_{b}^{\prime} $$ is computed as

(16.47)

Since the velocity $$ {\mathbf{v}}_{b}^{*} $$ is not known, it is customary to assume its direction to be that of the upwind velocity $$ {\mathbf{v}}_{C}^{*} $$. The expression of the a c coefficient in the pressure-correction equation may be written as

(16.48)

For the energy equation a zero flux Neumann-type boundary condition is applied.

For a specified mass flow rate at outlet, $$ \dot{m}_{b}^{\prime} $$ is zero and is simply dropped from the pressure correction equation with no modifications required for the coefficients of the boundary elements. By setting $$ \dot{m}_{b}^{\prime} $$ to zero in Eq. (16.34), an expression for the pressure correction at the boundary as a function of the pressure correction at the boundary cell centroid is obtained as

(16.49)

allowing the boundary pressure and density to be computed. For the energy equation a zero flux Neumann-type boundary condition is applied.

16.8.2.2 Supersonic Flow at Outlet

At a supersonic outlet none of the variables should be specified and the values of pressure, velocity, density, and temperature are extrapolated from the interior of the domain. Thus both $$ \dot{m}_{b} $$ and $$ p_{b} $$ are extrapolated from interior cells. This is equivalent to applying a Neumann boundary condition on pressure-correction, leading to the following modified a C coefficient

(16.50)

16.9 Computational Pointers

16.9.1 uFVM

For compressible flows a major modification to the algorithm arises in the assembly of the pressure equation through the inclusion of the convection like term. This is added to the cfdAssembleMdotTerm shown in Listing 16.1.

Listing 16.1

Script used to assemble the additional terms for the compressible pressure correction equation

The other important change is in the treatment of boundary conditions that now necessitates accounting for a variable density field. For example the supersonic inlet condition is implemented for the pressure correction equation as shown in Listing 16.2.

Listing 16.2

Implementation of a supersonic inlet condition

16.9.2 OpenFOAM®

In this section simpleFoam is extended to handle compressible fluid flow at all speeds. This entails the following modifications to simpleFoam: (i) the addition of the energy equation to be solved simultaneously with the continuity and momentum equations, (ii) the use of an equation of state relating density to temperature and pressure, (iii) and the introduction of the necessary modifications to the pressure correction equation and to a number of boundary conditions. The resulting code is denoted simpleFoamCompressible with many of the extensions added in the form of supplemental include files as shown in Listing 16.3.

Listing 16.3

The include files used in simpleFoamCompressible

The upwind.H and gaussConvectionScheme.H are used to force an upwind discretization on the convective term of the pressure correction equation. The bound.H class is used to bound variables within certain limits.

The createFields.H now includes the definition of the density field and other variables and constants related to compressible flow physics. The psiTermo class, depicted in Listing 16.4, provides access to the thermophysical relations that are part of the OpenFOAM® library [27], such as the perfect gas law described in Eq. (16.4).

Listing 16.4

An excerpt of the psiTermo class

The pressure and enthalpy fields are defined in the thermo class, displayed in Listing 16.5, and accessed as references in createFields.H.

Listing 16.5

Defining the pressure and enthalpy field in thermo class

The velocity is defined as in the incompressible version but the mass flux now includes density in its definition (Listing 16.6).

Listing 16.6

Defining the velocity and mass flux fields

In compressible flows, setting physical limits on some variables such as density and pressure can enhance robustness, especially during the first few iterations. This prevents variables from assuming non-physical values (like negative densities or pressures). Therefore bounds can be set as part of the case definition, as shown in Listing 16.7, and read in createFields.H.

Listing 16.7

Setting lower and upper bounds for the density and pressure fields

The momentum equation is defined with a slightly modified syntax that accounts for density and thermophysical property relations. The syntax of the linearized formula is given in Listing 16.8.

Listing 16.8

Syntax used to solve the momentum equation

The first instruction defines the finite volume discretization of the momentum equation in a vector form (the three components of the velocity are solved in a segregated manner despite the vectorial implementation). The system is implicitly relaxed and then solved with an iterative solver.

Once the momentum equation is solved, a new guess of the velocity field is obtained. This velocity field does not necessarily satisfy the continuity equation. To enforce mass conservation, assembly of the pressure correction equation is now required to correct the velocity. Following Eq. (16.19) the syntax used for that purpose is shown in Listing 16.9.

Listing 16.9

Syntax used to assemble the pressure correction equation

As for the incompressible case, in order to avoid checker boarding, the mDot mass flux field is evaluated using the Rhie-Chow interpolation but now taking into account also the density field, evaluated based on the thermo model as shown in Listing 16.10.

Listing 16.10

Calculation of mass fluxes at cell faces using the Rhie-Chow interpolation

It is worth mentioning that density is interpolated to faces using an upwind scheme in order to mimic the hyperbolic behavior of compressible flows.

The pressure correction equation is fully set and is solved using the syntax displayed in Listing 16.11.

Listing 16.11

Syntax for solving the pressure correction equation

After solving the pressure correction equation, variables that depend on pressure correction are updated. For the mass flux field this is performed using the syntax in Listing 16.12, this is similar to the incompressible flux correction.

Listing 16.12

Syntax to update the mass flux field

Where again the flux() function in Listing 16.12 updates the fluxes using directly the matrix coefficients and cell values. A simplified version of the flux() function is shown in Listing 16.13.

Listing 16.13

A simplified version of the flux( ) function where the flux correction mDotPrime is computed

In Listing 16.13 the correction flux mDotPrime is basically evaluated by performing a loop over the faces using the upper and lower coefficients of the matrix and multiplying these coefficients with the corresponding cell values.

Finally the velocity, density and pressure at cell centroids are updated using Eqs. (16.20), (16.21), and (16.22), as shown in Listing 16.14, where the variable alphaP is the explicit relaxation factor for pressure and density updates $$ \lambda^{p} $$, necessary for a stable SIMPLE solver.

Listing 16.14

Update of the velocity and pressure fields at cell centroids

In order to account for compressibility effects, the energy equation is introduced and the related temperature is calculated. In OpenFOAM®, the energy equation expressed in terms of specific static enthalpy $$ \left( {h = C_{p} T} \right) $$, given by Eq. (3.​61), is solved as depicted in Listing 16.15.

Listing 16.15

Solving the energy equation

Once the energy equation is solved, the new enthalpy is used to update the temperature and gas properties (e.g., specific heats).

In addition to the main solver, new total pressure and total temperature boundary conditions are implemented for subsonic inlet patches, these are often used boundary conditions for the simulation of compressible flows. The boundary conditions are defined in the directory “derivedFvPatchFields” and are next presented. For a better understanding, it may be beneficial to read Chap. 18 prior to going over the implementation process presented below.

totalPressureComp: This implements the total pressure condition at subsonic inlet. For that purpose the updateCoeffs() function is modified as shown in Listing 16.16, which indicates that after gathering the necessary data from the solver, the boundary static pressure is computed using Eq. (16.40) and the obtained values are stored in the defined newp variable.

Listing 16.16

Modified updateCoeffs() function for implementing the total pressure boundary condition at inlet

totalPressureCorrectorComp: This is also needed with a total inlet pressure boundary condition. Its role is to deal with the mass flow rate correction at inlet affecting the diagonal coefficient of the boundary element, as expressed by Eqs. (16.43) and (16.44). In the implementation, the contributions to the coefficients are reset to zero, as can be inferred from Listing 16.17, except for the gradientInternalCoeffs() that is required to return the correct values. This ensures that for both the divergence and laplacian operator one boundary condition is applied.

Listing 16.17

Script used to reset the diagonal coefficients and to return only the diffusion contribution or a total pressure boundary condition at inlet

The modified diagonal coefficient of the pressure correction equation for a boundary element is computed in Listing 16.18. Here the function deltaM() implements Eq. (16.44) as is, while the diffusion term “(-srUA*patch().magSf()*srho)” is removed from the coefficient of the pressure correction equation, as defined by the laplacian operator (see Chap. 8, computational pointers).

Listing 16.18

Script used to modify the diagonal coefficient of the boundary element for a total pressure boundary condition at inlet

totalTemp: This function implements for the energy equation the total temperature boundary condition at a subsonic inlet. The idea is to impose a static temperature as a Dirichlet boundary condition using Eq. (16.45). For that purpose the updateCoeffs() function is modified as in Listing 16.19.

Listing 16.19

Modified updateCoeffs() function for implementing the total temperature boundary condition at a subsonic inlet

At each iteration the temperature value is updated based on the inlet total temperature and the boundary velocity.

totalVelocity: This function, described in Listing 16.20, implements the updates to the velocity field required with total conditions applied at a subsonic inlet. For that purpose a Dirichlet boundary condition is used, with velocity values iteratively computed based on the calculated fluxes “mDot” at the boundary itself. The algorithm is based on grabbing the flux field “mDot” (updated with new values after solving the pressure correction equation by invoking the “flux()” function) and dividing the flux by the face area and the corresponding density.

Listing 16.20

Updating the velocity at a subsonic inlet for a total pressure boundary condition

Additionally, a clipping variable is introduced in order to prevent any “backflow” at the inlet. Here the “clip” variable may assume either a value of zero or one. In fact the “neg” function returns 1 and 0 for negative and positive values, respectively, preventing outward velocities to be accepted. On the other hand, the “inletDir” variable gives the velocity direction at inlet, as defined by the user.

16.10 Closure

In this chapter the incompressible segregated pressure based approach developed in the previous chapter was extended to handle compressible fluid flow at all speeds. This involved modifying the pressure correction equation to include a convection-like term that changes its type from elliptic to hyperbolic. It also required alterations to the momentum equations, the solution of the energy equation, as well as the addition of an equation of state. Just as critical, are the special boundary conditions needed in the simulation of compressible flows. A number of boundary conditions were presented as well as some implementation details.

The needed modifications to the base incompressible code represent a relatively small change to the bulk of any code and yet allow a drastic extension of its capabilities. The next chapter will present the additional techniques needed for dealing with the time averaged Navier-Stokes equations required for solving turbulent flow problems.

16.11 Exercises

Exercise 1

A portion of a gas-supply system is shown in Fig. 16.4. The mass flow rate $$ \dot{m} $$ in a pipe section is given by

where $$ \Delta p $$ is the pressure drop over the length of the pipe section, $$ \rho $$ is the gas density, and $$ C $$ is the gas conductance. The following data is known:

with the density related to the pressure via $$ p = \rho R^{\prime} $$ with $$ R^{\prime} = 2000 $$.

Fig. 16.4

A portion of a gas supply system

If the direction of the flow is as shown in the figure, find $$ p_{3} ,p_{4} ,p_{5} ,\dot{m}_{A} ,\dot{m}_{B} ,\dot{m}_{C} ,\dot{m}_{D} $$ and $$ \dot{m}_{E} $$ using the following procedure:

Start with a guess for $$ p_{3} ,p_{4} , $$ and $$ p_{5} $$.

Compute $$ \dot{m}^{*} $$ values based on the guessed pressures and densities.

Construct the pressure-correction equations and solve for $$ p_{3}^{\prime } ,p_{4}^{\prime } $$ and $$ p_{5}^{\prime } $$.

Update the pressures and the $$ \dot{m}^{*} $$ values

Do you need to iterate? Why?

Exercise 2

Consider the flow of an ideal gas in a converging nozzle shown in Fig. 16.5, where each of the control volumes has $$ \Delta x = 0.5 $$. The area of the various surfaces are $$ A_{{b_{i} }} = 3;\;A_{w} = 2.3;\;A_{e} = 1.6;\;A_{{b_{o} }} = 0.9 $$ with $$ R = 2078 $$ and $$ \gamma = 1.4 $$.

Fig. 16.5

Converging nozzle

The variable area flow is assumed to be one-dimensional and isentropic. At inlet the total pressure is $$ p_{o,i} = 100701.8\,{\text{Pa}} $$ and the stagnation temperature is $$ T_{o,i} = 303\,{\text{K}} $$. At exit the static pressure is $$ p_{e} = 10^{5}\,{\text{kPa}} $$. Setup the momentum and pressure correction equations for the three control volumes and obtain the values of the velocity, pressure, density, and temperature starting with uniform fields of values $$ M = 0.1\,\left(M {\text{is the Mach number}}\right),\,T = 290\,{\text{K}} $$, and $$ p = 10^{5}\,{\text{Pa}} $$. Perform three iterations. Note that there is no need to solve the energy equation as the temperature field can be extracted from the constant stagnation temperature condition.

Exercise 3

Consider the flow of an ideal gas in a diverging nozzle shown in Fig. 16.6, where each of the control volumes has $$ \Delta x = 0.5 $$. The area of the various surfaces are $$ A_{{b_{i} }} = 0.9;\,A_{w} = 1.6;\,A_{e} = 2.3;\,A_{{b_{o} }} = 3 $$ with $$ R = 2078 $$ and $$ \gamma = 1.4 $$.

Fig. 16.6

Diverging nozzle

The variable area flow is assumed to be one-dimensional and isentropic. At inlet the total pressure is $$ p_{i} = 1bar $$, the Mach number is $$ M_{i} = 1.2 $$, and the temperature is $$ T_{i} = 303\,{\text{K}} $$. At exit the flow remains supersonic. Setup the momentum and pressure correction equations for the three control volumes and obtain the values of the velocity, pressure, density, and temperature starting with uniform fields of values $$ M = 1.2,\,T = 303\,{\text{K}} $$, and $$ p = 1bar $$. Perform three iterations. Note that there is no need to solve the energy equation as the temperature field can be extracted from the constant stagnation temperature condition.

Exercise 4 (OpenFOAM®)

Define in the simpleFoamCompressible solver a new variable for the local Mach number to be visualized during simulation.

Exercise 5 (OpenFOAM®)

Modify in the totalPressureCorrectorComp boundary condition, the way Eq. (16.44) is imposed, using now the valueInternalCoeffs() function while resetting the gradientInternalCoeffs(). (Hint: consult Chaps. 11 and 19)

Exercise 6 (OpenFOAM®)

Check the rhoSimpleFoam solver that can be found in $FOAM_SRC/../applications/solvers/compressible/rhoSimpleFoam/pEqn.C and compare it with the algorithm described in this chapter.

Exercise 7 (OpenFOAM®)

Develop a compressible PISO algorithm and implement it starting with the simpleFoamCompressible code described in this chapter.

References

1.

Harlow FH, Amsden AA (1968) Numerical calculation of almost incompressible flow. J Comput Phys 3:80–93MATHCrossRef

2.

Harlow FH, Amsden AA (1971) A numerical fluid dynamics calculation method for all flow speeds. J Comput Phys 8(2):197–213MATHCrossRef

3.

Patankar SV (1971) Calculation of unsteady compressible flows involving shocks. Mechanical Engineering Department, Imperial College, Report UF/TN/A/4

4.

Issa RI, Lockwood FC (1977) On the prediction of two-dimensional supersonic viscous interactions near walls. AIAA J 15:182–188MATHCrossRef

5.

Hah C (1984) A Navier-Stokes analysis of three-dimensional turbulent flows inside turbine blade rows at design and off-design conditions. ASME J Eng Gas Turbines Power 106:421–429CrossRef

6.

Hah C (1986) Navier-Stokes calculation of three-dimensional compressible flow across a cascade of airfoils with an implicit relaxation method. AIAA Paper 86-0555

7.

Issa RI, Gosman D, Watkins A (1986) The computation of compressible and incompressible recirculating flows by a non-iterative implicit scheme. J Comput Phys 62:66–82MATHMathSciNetCrossRef

8.

Karki KC (1986) A calculation procedure for viscous flows at all speeds in complex geometries. Ph.D. thesis, Department of Mechanical Engineering, University of Minnesota

9.

Van Doormaal JP, Turan A, Raithby GD (1987) Evaluation of new techniques for the calculations of internal recirculating flows. AIAA Paper 87-0057

10.

Rhie CM, Stowers ST (1987) Navier-Stokes analysis for high speed flows using a pressure correction algorithm. AIAA Paper 87-1980

11.

Van Doormaal JP (1985) Numerical methods for the solution of incompressible and compressible fluid flows. Ph.D. Thesis, University of Waterloo, Ontario, Canada

12.

Van Doormaal JP, Raithby GF, McDonald BD (1987) The segregated approach to predicting viscous compressible fluid flows. ASME J Turbomach 109:268–277CrossRef

13.

Karki KC, Patankar SV (1989) Pressure based calculation procedure for viscous flows at all speeds in arbitrary configurations. AIAA J 27:1167–1174CrossRef

14.

Demirdzic I, Issa RI, Lilek Z (1990) Solution method for viscous flows at all speeds in complex domains. In Wesseling P (ed) Notes on numerical fluid mechanics, vol 29, Vieweg, Braunschweig

15.

Demirdzic I, Lilek Z, Peric M (1993) A collocated finite volume method for predicting flows at all speeds. Int J Numer Meth Fluids 16:1029–1050MATHCrossRef

16.

Moukalled F, Darwish M (2000) A unified formulation of the segregated class of algorithms for fluid flow at all speeds. Numer Heat Transf Part B: Fundam 37:103–139CrossRef

17.

Rhie CM (1986) A pressure based Navier-Stokes solver using the multigrid method. AIAA paper 86-0207

18.

Moukalled F, Darwish M (2001) A high resolution pressure-based algorithm for fluid flow at all-speeds. J Comput Phys 169(1):101–133MathSciNetCrossRef

19.

Turkel IE (1987) Preconditioning methods for solving the incompressible and low speed compressible equations. J Comput Phys 72:277–298MATHCrossRef

20.

Turkel IE, Vatsa VN, Radespiel R (1996) Preconditioning methods for low speed flows. AIAA Paper 96-2460, Washington

21.

Merkle CL, Sullivan JY, Buelow PEO, Venkateswaran S (1998) Computation of flows with arbitrary equations of state. AIAA J 36(4):515–521CrossRef

22.

Moukalled F, Darwish M (2006) Pressure based algorithms for single-fluid and multifluid flows. In: Minkowycz WJ, Sparrow EM, Murthy JY (eds) Handbook of numerical heat transfer, 2nd edn. Wiley, pp 325–367

23.

Patankar SV (1980) Numerical heat transfer and fluid flow. Hemisphere, NewYork

24.

Nerinckx K, Vierendeels J, Dick E (2005) A pressure-correction algorithm with mach-uniform efficiency and accuracy. Int J Numer Meth Fluids 47:1205–1211MATHCrossRef

25.

Nerinckx K, Vierendeels J, Dick E (2006) A mach-uniform pressure-correction algorithm with AUSM + Flux definitions. Int J Numer Meth Heat Fluid Flow 16(6):718–739MATHMathSciNetCrossRef

26.

Karimian SMH, Schneider GE (1995) Pressure-based control-volume finite element method for flow at all speeds. AIAA J 33(9):1611–1618MATHCrossRef

27.

OpenFOAM, 2015 Version 2.3.x. http://​www.​openfoam.​org

Part IV
Applications

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_17

17. Turbulence Modeling

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter addresses some of the challenges that arise when solving turbulent flow problems. It is not intended to provide a comprehensive account on turbulence modeling, rather, the intention is simply to introduce the subject and focus on the implementation details of some of the most popular turbulence models. The presentation is limited to incompressible turbulent fluid flow and begins with a general introduction to turbulence modeling. Then the Reynolds stress tensor that originates from the adopted averaging procedure and the Boussinesq hypothesis used in modeling the Reynolds stresses are presented. This is followed by a review of the k − ε and k − ω two-equation models. These are the most popular of the high Reynolds number and low Reynolds number turbulence models, respectively. The BSL and SST models are then introduced, both are derived by combining the k − ε and k − ω models so as to address their respective weaknesses. Finally the treatment of the near wall region is presented in detail.

17.1 Turbulence Modeling

In deriving the Navier-Stokes equation in Chap. 3 no mention was made to whether the flow is laminar or turbulent. Whereas laminar flows are stable, turbulent flows are chaotic, diffusive causing rapid mixing, time-dependent, and involve three-dimensional vorticity fluctuations with a broad range of time and length scales [1]. Turbulence typically develops as an instability of laminar flows appearing at a certain critical Reynolds number. In the fluid, these instabilities are caused by the amplification of the perturbation due to the highly non-linear inertial terms.

The most accepted theory of turbulence is based on the “energy cascade” concept developed by Kolmogorov [2, 3]. According to this theory, turbulence is composed of eddies of different sizes with each one possessing a certain amount of energy that depends on its dimension. The larger eddies break up transferring their energy to smaller size eddies in a chain process by which the smaller newly formed eddies undergo similar breakup processes and transfer their energy to even smaller eddies. This break up process continues until the smallest possible eddy size is reached. The smallest eddies are of scales at which the molecular viscosity is very effective at dissipating the turbulent kinetic energy as heat.

The smallest turbulent eddies are characterized by the Kolmogorov micro length (η) and time (t η ) scales given by

(17.1)

where v is the molecular kinematic viscosity and ε the average rate of dissipation of turbulent kinetic energy that will be defined later. In addition, the size of the largest eddies, which is also known by the integral length scale, is defined as being proportional to the size of the geometry involved.

Based on the energy cascade concept a direct numerical solution of the Navier-Stokes equation for turbulent flows necessitates the use of a very small time step limited by a Courant number below 1 and a fine mesh (Δx < η) resulting in a large number of grid points (proportional to Re ³) to resolve the entire spectrum of temporal and spatial turbulent scales involved. This computationally demanding approach, which is denoted in the literature by Direct Numerical Simulation (DNS), has been used by few workers [4–7] in a limited number of simple studies. Due to its prohibitive computational cost the DNS approach cannot currently be employed to solve industrial problems. Future advances in computer technology may change the situation in favor of the DNS.

To reduce the large computational cost associated with a direct solution of the Navier-Stokes equation, statistical analyses can be used to simplify the resolution of turbulent flows. The time-dependent nature of turbulence together with its wide range of time scales suggest that statistical averaging techniques can be applied to approximate random fluctuations. Time averaging, however, leads to correlations that are not known a priori arising from the nonlinear terms in the equations of motion. Modeling these transpiring correlations constitutes the classic closure problem of turbulence modeling.

Following the statistical approach, workers have devised methods that are computationally less intensive than the DNS. One such method is the large eddy simulation (LES) [8–11], in which large scale turbulent structures are directly simulated whereas small turbulent scales are modeled using sub-grid scale models.

The key concept in the LES is to filter the Navier-Stokes equation to determine which scales to keep and which scales to discard. This is done by applying a spatial statistical filter of the form

(17.2)

where the filter function retains values of v occurring on scales larger than the filter width Δ. The filter function F, is basically some function which is effectively zero for values of v occurring at small scales. Here the symbol 〈 〉 indicates a filtered variable.

Thus in the LES approach, turbulent structures of scales larger than the set minimum filter are not filtered. This has the advantage of directly resolving the larger eddies with the higher content of energy (anisotropic turbulence) while the smallest eddies are simply modeled. Accurate modeling of these eddies is possible since at the smaller scale (below the filter width) turbulence can be considered isotropic and independent of the flow type and boundary conditions. With the recent advances in computer technology the use of LES to solve industrial problems is gaining acceptance.

Nevertheless, currently the most popular approach for tackling industrial turbulent flow problems is the one based on solving the Reynolds Averaged Navier-Stokes (RANS) equations [12] where the statistical averaging is now based not on spatial averaging but on a proper time. The key approach is to decompose the flow variables into a time-mean value component and a fluctuating one (Fig. 17.1), substituting in the original equations, and time-averaging the obtained equations. Even though the name refers to the Navier-Stokes equation, the decomposition is applied to all governing equations. Two tracks for averaging the equations have been followed. The standard Reynolds averaging, which is used to derive the Reynolds-Averaged Navier-Stokes (RANS) equations [12], and the mass-weighted or Favre averaging technique employed with turbulent compressible flows and leading to the Favre-Averaged Navier-Stokes (FANS) equations [13]. Following either path, the intention is to model all scales of turbulent flow. Therefore with this approach the mesh size limitation is not as constraining as in the DNS and LES approaches.

Fig. 17.1

Fluctuating and mean variable components

In what follows the development of the RANS equations for an incompressible flow is presented.

17.2 Reynolds Averaging

Let ϕ represents at time t and position x the instantaneous value of any of the flow variables involved (v, p, e, h, T, ρ, etc.). Then, as shown in Fig. 17.1, it is decomposed into a mean value component $$ \overline{\phi }({\mathbf{x}},t) $$ and a fluctuating component $$ \phi^{\prime}({\mathbf{x}},t) $$ such that

(17.3)

the mean value $$ \overline{\phi } $$ is computed by any of the three Reynolds averaging techniques [12] presented below, of which the time averaging is the most widely used.

17.2.1 Time Averaging

Time averaging represents the average of a quantity over a time interval and is suitable for steady turbulent flows, that is flows which, on average, do not vary with time. If T is the interval over which averaging is performed, then $$ \overline{\phi } $$, which depends only on location, is computed as

(17.4)

If $$ \overline{\phi } $$ varies slowly with time in comparison with the time scale of turbulent fluctuations, the above equation is replaced by

(17.5)

17.2.2 Spatial Averaging

Spatial averaging represents the average of a quantity over a space interval or a volume V and is suitable for homogeneous turbulence. In this case $$ \overline{\phi } $$, which only depends on time, is computed as

(17.6)

17.2.3 Ensemble Averaging

Ensemble averaging, which is suitable for any type of turbulent flows including unsteady turbulent flows, represents the average of many identical quantities at a certain time. If the number of identical quantities is designated by N, then $$ \overline{\phi } $$, which in this case is a function of space and time, is given by

(17.7)

17.2.4 Averaging Rules

If ϕ and φ are two variables and ϕ′ and φ′ are their fluctuating components, then some of the averaging rules needed in deriving the RANS equations include the following:

(17.8)

17.2.5 Incompressible RANS Equations

The incompressible Reynolds-averaged Navier–Stokes equations are based on time-averaged variables. Decomposing the velocity, pressure, and temperature fields into

(17.9)

and substituting v, p, and T by their decomposed expressions in the incompressible continuity, momentum, and energy equations given by Eqs. (3.​13), (3.​39), and (3.​78), respectively, assuming a Newtonian fluid, and taking the time average, these equations are transformed to

(17.10)

(17.11)

(17.12)

The Reynolds averaged forms of Eqs. (17.10)–(17.12) are obtained as

(17.13)

(17.14)

(17.15)

The above Reynolds averaged equations are similar to the original conservation equations with the exception of the additional averaged products of the fluctuating components due to the non-linear terms. This introduces six new unknowns (the components of the tensor $$ - \rho \overline{{{\mathbf{v^{\prime}v^{\prime}}}}} $$, known as the Reynolds stress tensor $$ {\varvec{\uptau}}^{R} $$) to the momentum equations and three new unknown turbulent heat fluxes $$ \left( {{\dot{\mathbf{q}}}^{R} = - \rho c_{p} \overline{{{\mathbf{v^{\prime}}}T^{\prime}}} } \right) $$ to the energy equation. The expanded forms of the Reynolds stress tensor $$ {\varvec{\uptau}}^{R} $$ and turbulent heat flux vector are given by

(17.16)

Consequently the set of RANS equations is not a closed set and to be able to solve it additional equations for the unknown Reynolds stress components are required. The process of calculating these Reynolds stresses is denoted in the literature by turbulence modeling. Attempting to develop such equations by using the original conservation equations results in additional unknowns (such as triple products of the fluctuating components) complicating the problem further. The Reynolds stress tensor comes from the non-linear convection term of both momentum and temperature confirming that the turbulence itself is the effect of a non-linear phenomena highly sensitive to any perturbation. Therefore any linear averaging of the equations, like the Reynolds averaging techniques, cannot reduce the order of the problem. The complexity is actually recursive in that trying to develop additional equations for the triple products, quadruple products arise and so on. To overcome this problem, any turbulence model has to close the system of equations by expressing the non-linear fluctuating stress components only in terms of the mean components as described next.

17.3 Boussinesq Hypothesis

The direct modeling of the Reynolds stress tensor is based on the Boussinesq hypothesis [14–16], which in analogy with Newtonian flows assumes the Reynolds stress to be a linear function of the mean velocity gradients such that

(17.17)

which for incompressible flows reduces to

(17.18)

where from now on the over bar is dropped from the averaged quantities to simplify the notation, k is the turbulent kinetic energy defined as

(17.19)

and μ t the turbulent eddy viscosity (in analogy with molecular viscosity), which is now flow, not fluid, dependent. With this approximation, the problem of calculating the Reynolds stress components is transformed into computing the turbulent kinetic energy and turbulent viscosity. For incompressible flows the term −(2/3)ρk I in the Reynolds stress is usually combined with the pressure gradient term by defining a turbulent pressure p as

(17.20)

thereby reducing the unknowns to μ t alone, which is evaluated using a variety of turbulence models.

In a similar way, the turbulent thermal fluxes are calculated in analogy with Fourier’s law such that

(17.21)

where k t is the turbulent thermal diffusivity calculated as will be explained later.

17.4 Turbulence Models

Several turbulence models based on the Boussinesq hypothesis have been developed to express the turbulent viscosity, μ t , in terms of a velocity $$ (\sqrt k ) $$ and length $$ \left( \ell \right) $$ scales such that

(17.22)

These models are grouped, into four main categories:

Algebraic (Zero-Equation) Models

One-Equation Models

Two-Equation Models

Second-Order Closure Models

None of the developed models is universally applicable to all flow conditions. Though each group has certain advantages and strengths.

The zero-equation models [17–19] use an algebraic equation to compute μ t without the need to solve any differential equation. The one-equation models [20–22] require solving only one transport differential equation to compute the turbulent eddy viscosity. Two-equation turbulence models [23–35] necessitate the solution of two transport equations for the calculation of μ t . The second-order closure models [36–41] are the most computationally expensive as separate transport equations are solved for the individual turbulent fluxes (6 equations).

The two-equation turbulence models are the most popular in terms of usage in the simulation of industrial applications, requiring the solution of two transport equations while delivering accurate enough predictions. The k − ε model of Jones and Launder [23] was amongst the earliest two equation models and the most popular, while the k − ω model of Wilcox [28, 29] comes as a close second. Both models had undergone many modifications and improvements [26, 30], which have greatly extended their applicability.

17.5 Two-equation Turbulence Models

17.5.1 Standard k − ε Model

The well-known k − ε model of Jones and Launder [23], known as the standard k − ε model, is based on the Boussinesq approximation with the turbulent viscosity μ t and thermal diffusivity k t formulated as

(17.23)

where ε is the rate of dissipation of turbulence kinetic energy per unit mass due to viscous stresses given by

(17.24)

In the model, the turbulent kinetic energy k and the turbulent energy dissipation rate ε are computed using

(17.25)

(17.26)

where

(17.27)

with the turbulent Prandtl number (Pr t ) and other model constants assigned the following values: C ε1 = 1.44, C ε2 = 1.92, C μ  = 0.09, σ k  = 1.0, σ ε  = 1.3 and Pr t  = 0.9.

The compact form of the production of turbulent energy term is given by

(17.28)

while its expanded form for incompressible flow can be obtained by multiplying Eq. (3.​75) by μ t .

In the derivation of the standard k − ε model the flow is assumed to be fully turbulent and the effects of molecular viscosity to be negligible. Therefore the standard k − ε model is a high Reynolds number turbulence model valid only for fully turbulent free shear flows that cannot be integrated all the way to the wall.

Modeling flows close to solid walls requires integration of the two equations over a fine grid in order to correctly capture the turbulent quantities inside the boundary layer as well as the corrections for low Reynolds number effects. A turbulence model that can be integrated all the way to the wall is denoted in the literature by a low Reynolds number turbulence model or a low Reynolds number version. Several so called low Reynolds number k − ε models have been proposed over the years (see Patel et al. [42] and Wilcox [29] for a review). The idea behind their development is to damp the turbulent viscosity near the wall through the use of a damping function that tends towards zero as the distance to the wall decreases, i.e., as the wall is approached. Constants multiplying source terms in the turbulent dissipation equation are in some models also damped. All models share the same basic structure differing in the tuning of the damping functions and in some extra sources in the dissipation equation.

The only exception to this rule is the k − ω turbulence model of Wilcox [28, 29], which can be integrated all the way to the wall without the need to employ damping functions. Still the model can also be used as a high Reynolds number model.

One of the main drawback of the two-equation models is the so called stagnation point anomaly. In high strain regions the two-equation models tend to over predict the turbulence kinetic energy production P k . This was originally recognized in stagnation point flows, but it is a more widespread anomaly. The problem is an overproduction of the turbulence kinetic energy for the case when a moderate level of k is subjected to a large rate of strain. This may be attributed to an underestimation of the sink term and/or an overestimation of the turbulent viscosity. These ideas could be merged together into a bound on the local turbulent time scale t s =k/ε (Medic and Durbin [43]). The first step is to reformulate the expression for the turbulent viscosity as

(17.29)

Then using t s , the ε equation is modified to

(17.30)

Finally, to constrain the Reynolds stress tensor to be positive definite, a limiter is applied on tsuch thats

(17.31)

As a consequence, at a large rate of strain, P k grows at the rate S t rather than $$ S_{t}^{2} $$.

17.5.2 The k − ω Model

It has already been mentioned how the family of k − ε models are well behaved for free-shear flows while are likely to fail in predicting flows with adverse pressure gradient. Another class of models, for which the equation for ε is replaced by an equation for ω, where ω is the rate at which turbulence kinetic energy is converted into internal thermal energy per unit volume and time, is better capable of predicting separated flows.

The first complete turbulence model in this category was proposed by Kolmogorov [27]. In addition to the same equation for k, Kolmogorov developed a second equation for ω. The reciprocal of ω serves as a local turbulence time scale while the turbulence length scale is given by $$ \sqrt k /\omega $$. The k − ω model introduced next is proposed by Wilcox [29] as an evolution to the well-known k − ω model that Wilcox reported in [28].

The k − ω model of Wilcox [29] is similar in structure to the k − ε model and is also based on the Boussinesq approximation. Two transport equations are solved to determine the two (large) scales of turbulence. The specific turbulence dissipation ω is defined as

(17.32)

The advantages of replacing the ε-equation by the ω-equation are: (i) the second is easier to integrate (more robust), (ii) it can be integrated through the sub-layer without the need for additional damping functions, and (iii) it performs better for flows with weak adverse pressure gradient. The conservation equations are written as

(17.33)

(17.34)

with the model constants assigned the values

where

(17.35)

The major drawback of the Wilcox model is its sensitivity to the free stream [30] specified values, which leads to strong dependence of the solution on the arbitrary specification of the free stream ω. This dependence is not present in the k − ε model.

17.5.3 The Baseline (BSL) k − ω Model

The Baseline (BSL) model developed by Menter [32] combines the k − ε and k − ω models so as to take advantage of their respective strength, i.e. the robustness of the k − ω model near wall surfaces due to its simple low Reynolds number formulation and its ability to compute flows with weak adverse pressure gradients accurately, and the better performance of the k − ε model near the boundary layer edge and away from walls, due to its insensitivity to the free stream values. The basis of this technique is the transformation of the k − ε model to a k − ω formulation. This is an exact conversion, except for small contributions from the diffusion term due to the difference in the diffusion coefficients of the k and ε equations. The k − ω formulation of the k − ε model is given by

(17.36)

(17.37)

The differences between this formulation and the original k − ω model are in the additional cross-diffusion term appearing in the equation for ω and in the modeling constants that are given by

The BSL k − ω model is derived by multiplying the k − ω (Eqs. 17.33 and 17.34) with a blending function F ₁ and the k − ω formulation of the k − ε model equations (Eqs. 17.36 and 17.37) by (1 − F ₁), yielding the following equations for k and ω [32]:

(17.38)

(17.39)

These equations are formally very similar to those of the standard k − ω model, however all their coefficients depend on the blending function F ₁, in the form

(17.40)

with the constants of the original k − ω model used in Eq. (17.39) given by

The blending function F ₁ depends on the solution variables and on the distance d ⊥ from the nearest wall and is given as

(17.41)

where

(17.42)

and

(17.43)

The BSL model has a similar performance as the k − ω model for boundary layer flows and is nearly identical to the k − ε model for free shear flows. Its robustness is close to that of the k − ω model.

17.5.4 The Shear Stress Transport (SST) k − ω Model

Further modifications to the BSL model yields the Shear Stress Transport (SST) [32–35] model which, when compared to other eddy-viscosity models, has an improved adverse pressure gradient performance. The first modification is related to satisfying Bradshaw’s assumption, which states that the principal shear stress and the turbulent kinetic energy in the boundary layer are linearly related via an equation of the form

(17.44)

On the other hand, the principal shear stress for conventional two-equation turbulence models can be computed as

(17.45)

where Ω is the vorticity. In flows with adverse pressure gradient the ratio of production of turbulent kinetic energy to its dissipation rate could be much larger than one, thereby substantially violating Bradshaw’s hypothesis. For Eq. (17.44) to be satisfied within the framework of eddy-viscosity models, Menter [35] modified the turbulent viscosity μ t in the SST k − ω model by bounding it according to

(17.46)

where a ₁ = 0.31, S t is the magnitude of the strain rate defined in Eq. (17.31), and F ₂ is given by [35]

(17.47)

Moreover, to maintain the original formulation of the eddy-viscosity for free shear layers, the same blending function approach as for the baseline model is also adopted in the SST k − ω model. The k and ω equations are given by Eq. (17.38) and Eq. (17.39), respectively.

The second modification is related to the production of turbulence kinetic energy P k in the k equation (Eq. 17.38), which is replaced by $$ \tilde{P}_{k} $$ given by

(17.48)

where ε is obtained from Eq. (17.32) and the blending function F ₁ is calculated as in the BSL model via Eqs. (17.41) and (17.42) with the coefficients computed by Eq. (17.40) using the following model constants:

In addition, the turbulent thermal conductivity and effective turbulent viscosities for k and ω are computed as

(17.49)

17.6 Summary of Incompressible Turbulent Flow Equations

The incompressible time-averaged continuity, momentum, energy, turbulence kinetic energy, turbulence dissipation rate, and specific dissipation rate equations can be written, respectively, as

(17.50)

(17.51)

(17.52)

(17.53)

(17.54)

(17.55)

All these equations are similar in structure and can be written in the general form given by Eq. (3.​93). As such, their discretization follows the general procedures presented in previous chapters. A summary of their discretized forms is given in the next section.

17.7 Discretization of the Turbulent Flow Equations

The discretization of the unsteady, convection, and diffusion terms appearing in the conservation equations for turbulent flows, Eqs. (17.50)–(17.55), follows the procedures described in previous chapters. Moreover the discretization of the momentum and energy equations lead to the same algebraic equations given by Eqs. (15.​74) and (16.​29), with molecular viscosity and thermal conductivity replaced by (μ + μ t ) and c p (μ/Pr + μ t /Pr t ), respectively. As the flow is incompressible, the terms involving ∇ · v are set to zero in these equations. Moreover, at low speeds the dissipation terms involving Φ and Ψ in the energy equation being very small are usually neglected. Another difference is related to the implementation of boundary conditions at a wall, which will be explained later. The discretized equations for k, ε and ω are presented below assuming a first order Euler scheme for the discretization of the unsteady term and a high resolution scheme for the discretization of the convection term applied in the context of a deferred correction approach.

17.7.1 The Discretized Form of the k Equation

The final algebraic form of the turbulence kinetic energy equation can be written as

(17.56)

where the coefficients are given by

(17.57)

The discretized form of the production of turbulent kinetic energy P k is given by Eq. (16.​27) with molecular viscosity replaced by turbulent viscosity. Moreover, similar to other variables, under relaxation of the turbulence kinetic energy equation is usually required.

17.7.2 The Discretized Form of the ε Equation

The final algebraic form of the turbulence dissipation rate equation can be written as

(17.58)

where the coefficients are given by

(17.59)

Moreover, similar to other variables, under relaxation of the turbulence dissipation rate equation is usually required.

17.7.3 The Discretized Form of the ω Equation

The final algebraic form of the specific turbulence dissipation equation can be written as

(17.60)

where the coefficients are given by

(17.61)

The expressions for $$ a_{C}^{add} $$ and $$ b_{C}^{add} $$ depend on the formulation of the k − ω model used and the different expressions are given as follows:

Original formulation of the k − ω model

(17.62)

The k − ω formulation of the k − ε model

(17.63)

The BSL and SST formulation of the k − ω model

(17.64)

The discretized form of $$ (\nabla k \cdot \nabla \omega )_{C} $$ is computed as

(17.65)

Again under relaxation of the specific turbulence dissipation equation is usually required.

17.8 Boundary Conditions

17.8.1 Modeling Flow Near the Wall

As a turbulent flow approaches a wall its mean and fluctuating components of velocity, and consequently k, vanish creating large gradients. In addition, the very high turbulent stresses away from the wall, decrease in the near wall layer to values of magnitude comparable to those of the viscous stresses. Therefore if the near wall layer is to be resolved, a substantial number of grid points will be required.

Low Reynolds number turbulence models are capable of simulating the dampening effects of the wall but at the expense of using a very large number of grid points. This is the unavoidable cost that has to be payed if accurate solutions of the flow in the near wall region is required.

On the other hand, the high Reynolds number turbulence approach, exemplified by the standard k − ε model, avoids the need to resolve the near wall layer through the use of wall functions. In this method, theoretical profiles between the boundary surface and the first near-wall node are assumed and superimposed. Compared to the previous approach, wall functions reduce significantly the computational cost. The main disadvantage of this methodology however, is related to the validity of these profiles, which are only known and justified in near-equilibrium boundary layers. Details regarding this special treatment is explained next.

17.8.2 Standard Wall Functions

The wall functions approach is based on the universal flow profiles in the boundary layer along a wall, which can be divided into three regions [1] designated by the viscous sublayer (0 < d ⁺ < 5), the buffer sublayer (5 < d ⁺ < 30), and the inertial sublayer (30 < d ⁺ < 200), respectively, with the normalized distance to the wall d ⁺ defined as

(17.66)

where d ⊥ is the normal distance to the wall, v is the kinematic viscosity (= μ/ρ), and u τ is the friction velocity expressed in terms of the wall shear stress τ w as

(17.67)

where $$ |\tau_{w} | $$ is the magnitude of the wall shear stress. Measurements and direct numerical simulations have shown that turbulence is negligible in the viscous sublayer, viscous effects are small in the inertial sublayer, while both effects are important in the buffer layer [44] with the maximum turbulent production occurring at nearly d ⁺ = 12, with the location slightly dependent on the Reynolds number making modeling of the flow in the buffer region very difficult. Because of this, turbulence models avoid the buffer layer near a wall by placing the first internal grid point either in the viscous or the inertial sublayer. The practice of placing the first grid point in the viscous sublayer is adopted with low Reynolds number turbulence models while the other practice is used with high Reynolds number turbulence models. The empirical relations applicable in the viscous sublayer are given by [45]

(17.68)

where u ⁺, k ⁺, ε ⁺, and ω ⁺ are the normalized velocity parallel to the wall, normalized turbulence kinetic energy, normalized turbulence dissipation rate, and normalized turbulence frequency, respectively. In the general case of a moving wall with a velocity v w , these variables are defined as

(17.69)

where $$ |{\mathbf{v}} - {\mathbf{v}}_{w} |_{||} $$ is the magnitude of the velocity parallel to the wall.

A comparison of the above profiles with data obtained from direct numerical simulation reveals that velocity and dissipation rate remain in good agreement up to d ⁺ = 10, while the turbulence kinetic energy is over estimated at values of d ⁺ > 5. Finally in the low Reynolds turbulence formulation, the k − ω based models just require a boundary treatment that satisfies the model asymptotic values. On the other hand, in the k − ε based models a damping function is added for the eddy viscosity equation that mimics the direct effect of molecular viscosity on the shear stress [25]. In the inertial sub-layer, the momentum profile is derived assuming a one-dimensional Couette flow with zero pressure gradient. Profiles for the turbulence quantities can be derived for a specific turbulence model. For the k − ε and k − ω models these profiles are given by

(17.70)

where the von Karman constant κ is assigned the value 0.41, C μ  = β $$^{*} $$ = 0.09 and B = 5.25. Data obtained from Direct Numerical Simulation (DNS) indicate excellent agreement for the velocity profile. On the other hand, turbulent quantities are less accurate.

As shown in Fig. 17.2, when solving a turbulent flow problem, modifications to the conservation equations are made at the first interior point C in the control volume next to the wall. The value of d ⁺ at that location, denoted by $$ d_{C}^{ + } $$, is first calculated to infer whether the point lies in the viscous or inertial sublayer. The value of $$ d_{C}^{ + } $$ is computed from the definition of d ⁺ and the value of u τ obtained from the law of the wall as

(17.71)

Fig. 17.2

A boundary control volume next to a wall

The transition from the viscous to the inertial layer is assumed to occur at a limiting value of d ⁺, denoted by $$ d_{\lim }^{ + } $$. Different values for $$ d_{\lim }^{ + } $$ are reported in different sources. All values however are between 11 and 12. A value of 11.06 is adopted here. This limiting value marks the intersection between the logarithmic and the linear profile. If $$ d_{C}^{ + } < d_{\lim }^{ + } $$ then the grid point lies in the viscous sublayer, otherwise it is located in the inertial sublayer.

If the first grid point is in the viscous sublayer, then the flow is assumed to be laminar and the viscosity at the wall is set equal to the laminar viscosity μ and the shear stress is computed as for laminar flows. A fixed value of zero is imposed on the turbulence kinetic energy with the production of turbulence kinetic energy at the first interior point modified by assuming that the shear stress is constant over the control volume with its value computed as

(17.72)

In the standard k − ε model the dissipation rate of turbulence kinetic energy at the centroid of the first control volume next to the wall is computed by setting the laminar viscosity equal to the turbulent viscosity to yield

(17.73)

whereas in the k − ω model the value of the turbulence frequency ω C is computed from the analytical solution in the viscous sublayer as

(17.74)

If $$ d_{C}^{ + } > d_{\lim }^{ + } $$ then the grid point is located in the inertial sublayer and the logarithmic wall functions are applied at the first interior point C. The implementation process involves computing the shear stress using the logarithmic wall function as

(17.75)

where the fact that

(17.76)

has been used. This shear stress is used in solving the momentum equation either by invoking its value directly as a source term (τ w S b ) or via a modified viscosity at the wall μ w computed as

(17.77)

with the vector form of the wall shear stress expressed as

(17.78)

In either case the implementation follows the procedures described in Chap. 15.

It is worth noting that the shear stress can also be formulated in terms of the normalized quantities as

(17.79)

In solving the turbulence kinetic energy equation, the value of k is assumed to prevail over the control volume (i.e., a zero gradient for k is used) with the term representing the production of the turbulence kinetic energy at the first interior point next to the wall modified by assuming that the shear stress is constant over the control volume with its value equal to that at the wall, while the velocity gradient is computed from the wall function as

(17.80)

Therefore, if the first interior point lies in the inertial sublayer, the production term in the turbulence kinetic energy equation is computed as

(17.81)

It is also useful to formulate the production term P k in terms of the normalized parameters. Starting with Eq. (17.72), the generic production term can be written as

(17.82)

In the k − ε model the ε equation is not solved at the first interior point next to the wall. Rather its value is set by requiring the dissipation of turbulence kinetic energy to be equal to its production rate such that

(17.83)

If the k − ω model is used with wall functions, the same procedure is used. For the k equation the same modified production term is obtained since C μ  = β $$^{*} $$. The ω equation is not solved for the first interior point and its value is set again by requiring dissipation of turbulence kinetic energy to be equal to its production rate such that

(17.84)

17.8.3 Improved Wall Functions

The above formulation is valid under local equilibrium conditions and results in a zero viscosity (Eq. 17.77) when τ w vanishes, since $$ u_{\tau } = \sqrt {\tau_{w} /\rho } $$, as is the case at reattachment and separating points. A generalization to the above formulation valid under local non-equilibrium conditions has been proposed for the k − ε model by Launder and Spalding [46]. In their work, $$ \sqrt k $$ is used as the characteristic turbulent velocity scale, instead of the friction velocity, through the identity

(17.85)

such that the wall viscosity and shear stress become

(17.86)

where $$ d_{C}^{*} $$ is defined using u $$^{*} $$ as

(17.87)

Equation (17.86) clearly indicates that the turbulent viscosity does not vanish when τ w  = 0.

Similar to the standard wall functions case, the value of $$ d_{C}^{*} $$ is first computed. If the value of $$ d_{C}^{*} < d_{\lim }^{*} = 11.06 $$ then the first point is in the viscous sublayer and the procedure described for the standard wall functions is used.

If the value of $$ d_{C}^{*} > d_{\lim }^{*} $$ the first interior grid point is located in the inertial sublayer and the wall viscosity is computed via Eq. (17.86). Using this viscosity the wall shear stress is obtained and implemented as explained earlier. To find k C , the k-conservation equation is solved. The procedure described with the standard wall functions for calculating the production and dissipation terms in the near wall control volume, assumed that the values of k C and ε C prevail over the entire control volume. Since the P k and ε values vary drastically across the near-wall cell, evaluating them at the cell centre in discretizing the k equation leads to inaccurate approximations. To improve predictions, Launder and Spalding [46] suggested suitable approximations for their cell-average values. Starting with the production term, its average value is computed as

(17.88)

Invoking Eq. (17.86), the average production term is found to be

(17.89)

Then, the volume integral of the production term is obtained as

(17.90)

To calculate an average turbulence dissipation rate, the integrated value of dissipation is set equal to the production rate resulting in

(17.91)

The integral is evaluated by expressing the shear stress and velocity gradients as

(17.92)

Thus

(17.93)

and the average turbulence dissipation rate is computed as

(17.94)

while its volume integral is found to be

(17.95)

As for the standard wall functions, the ε equation is not solved at the first interior point next to the wall and its value is set using Eq. (17.83). Moreover, similar equations can be developed for use with the k − ω model by transforming ε into ω via Eq. (17.32).

17.8.4 Scalable Wall Functions

The wall functions approach is most accurate when the first grid point in the near wall region lies in the inertial sublayer at a normalized distance $$ d^{*} > d_{low}^{*} $$ where, depending on the numerical formulation, $$ d_{low}^{*} \approx 20 $$. This represents a serious limitation in situations where the boundary layer is very thin as it cannot be resolved with a coarse near-wall grid. The scalable wall function approach developed in [47, 48] overcomes this hurdle by slightly modifying the calculation of the wall shear stress by redefining u ⁺ as

(17.96)

where

(17.97)

With this formulation, the definition of $$ \tilde{d}^{*} $$ becomes independent of the grid spacing as it prevents the first grid point from being located in the viscous sublayer leading to consistent results for grids of arbitrary refinement. The simulation error introduced is related to not accounting for the viscous sublayer, which is the case for all wall function formulations. It should be clarified however that this error can be significant for flows with relatively low Reynolds number. The implementation of the scalable wall functions is straightforward whereby the procedures described above remains unchanged with the exception of replacing $$ {d}^{*} $$ or $$ {d}^{ + } $$ by, respectively, $$ \tilde{d}^{*} $$ or $$ \tilde{d}^{ + } $$.

This approach is usually used when the details of the boundary layer is not of interest. If the purpose of using a fine grid near the wall is to examine the details of the boundary layer then a low Reynolds number model should be used as explained next.

17.8.5 Wall Boundary Conditions for Low Reynolds Number Models

With low Reynolds number turbulence models a fine grid resolution must be used in the near wall region in order to properly resolve the viscous sublayer allowing laminar flow boundary conditions to be applied. Therefore, the boundary condition to be used at the wall in the momentum equation is the no slip condition presented in Chap. 15 with no need to be repeated here.

The k − ω and k − ε turbulence models and their variants are examples of this type. For all these models, the asymptotic boundary conditions applicable for k, ε and ω are set to

(17.98)

The value for ω w given by Eq. (17.98), which is intended to be applied at the first interior grid point next to the wall, is valid for grid points located at d $$^{+} $$ or d $$^{*} $$ < 2.5 with 15–20 nodes needed in that region for grid independent solutions. The factor of 10 is introduced into Eq. (17.98) based on the recommendation of Menter as it eliminates the need to specify ω at any other internal point beyond the one next to the wall.

17.8.6 Automatic Near-Wall Treatment

With the wall functions method the normalized distance to the wall is first calculated to infer wether the first interior point lies in the viscous or inertial sublayer. In the viscous sublayer the flow is treated as laminar. Because the standard k − ε model is valid in the fully turbulent regions and does not include damping functions to model viscous effects it introduces error into the solution. To eliminate this error care should be exercised to make sure that the first interior point is in the log region. This however eliminates the influence of the viscous sublayer, which may be significant on the solution. Therefore it is desirable to have the option of resolving the viscous sublayer without the stringent requirement of a very fine grid near the wall. This is possible with the k − ω model and its variants as the ω equation can be integrated all the way to the wall without the need for any additional damping functions. The idea is to develop a method that switches automatically between the low and the high Reynolds number formulation based on the value of the normalized distance to the wall. This task is achievable by the ω equation because of its known analytical solutions in the viscous and inertial sublayers. For that purpose, both solutions are blended smoothly according to [34]

(17.99)

where

(17.100)

The shear stress in the momentum equation is computed as

(17.101)

with the values of the velocities u τ and u $$^{*} $$ in the near wall region calculated using

(17.102)

(17.103)

In solving the k equation, the gradient at the wall is set to zero and the production in the near wall cell is altered to

(17.104)

Based on the grid spacing, this blending approach permits a smooth shift of the wall treatment from a viscous sublayer to a wall function.

17.8.7 Near-Wall Heat Transfer

Similar to velocity profiles, near wall temperature profiles should also be corrected when high Reynolds number turbulence models are used. These profiles are obtained by an adjusted Reynolds analogy from the velocity profiles by altering the log-law to provide an equation that relates the value of temperature at the near wall node T C , to that at the wall T w , and to the wall heat flux q w . The procedure starts by defining a normalized temperature T ⁺ as

(17.105)

where T $$^{*} $$ is the modified friction temperature given by

(17.106)

and other variables are as defined earlier. Then combining the above two equations, the normalized temperature equation becomes

(17.107)

For the standard wall functions formulation, if the first interior point is located in the viscous sublayer then the normalized temperature is calculated as

(17.108)

whereas if it lies in the inertial sublayer then it is computed using the law of the wall as

(17.109)

where

(17.110)

and Pr is the laminar Prandtl number. For the scalable wall functions formulation the same equation is used with d ⁺ replaced by $$ \tilde{d}^{ + } $$, as explained earlier. With the automatic near wall treatment approach, the equation suggested by Kader [49], which blends the viscous sublayer with the law of the wall, is used. In fact this approach may also be used with the standard and scalable wall functions approaches. According to this formula the normalized temperature is computed as

(17.111)

with the blending function Γ given by

(17.112)

Moreover, Eq. (17.107) can be interpreted in two different ways depending on the physical boundary condition imposed on temperature. For a given wall heat flux boundary condition, the numerical condition for T w will be a fixed value, iteratively updated, given by

(17.113)

If, instead, temperature is imposed on the boundary, then the temperature gradient must be held fixed numerically and calculated as

(17.114)

17.8.8 Other Boundary Conditions

Beside walls, conditions at other boundaries are needed. This include inlet, outlet, and symmetry boundary conditions. At inlet to a domain the values of the turbulence kinetic energy and dissipation rate, which are usually unknown, are required. If the values are known from measurements then they should be used, otherwise they must be estimated. The easiest way is to assign the values for k and ε. Values may also be specified via the turbulence intensity I defined as

(17.115)

from which the turbulence kinetic energy is obtained as

(17.116)

A value of turbulence intensity between 1 and 10 % is usually used with values less than 1 % considered low while values higher than 10 % considered high. The values of the turbulence dissipation rate ε and turbulence frequency ω are computed from Eqs. (17.23) and (17.32) by specifying a turbulence length scale whose value is dependent on the largest eddy dimension but it is usually set to one-tenth of the width of a shear layer or the domain size, with their expressions given by

(17.117)

The value for ε and ω may also be computed from knowledge of k and the turbulent to laminar viscosity ratio using

(17.118)

At an outlet and a symmetry boundary, the treatment for k, ε and ω is similar to that for the general scalar variable $$ \phi $$ presented in previous chapters and is deemed unnecessary to be repeated.

17.9 Calculating Normal Distance to the Wall

In the BSL and SST turbulence models, the normal distance to the nearest wall d ⊥ is needed over the entire domain to determine the interface between the computation regions of k − ε and k − ω, as reflected by Eq. (17.42) for the BSL model and (17.47) for the SST model. Search procedures to compute d ⊥ are computationally expensive in three-dimensional situations even for fixed grids. The situation gets worse with a moving grid as the search has to be repeated at every time step. This has forced workers to introduce approximations in the calculation of d ⊥ that incur large errors.

To avoid the expensive search procedures, techniques based on solving differential equations for d ⊥ have been developed. These methods are based on solving a Poisson, Eikonal, or Hamilton-Jacobi equations [50–53]. The attraction in these equations is their composition which involves gradient and/or Laplacian operators that are readily available in CFD solvers. This renders the approach easy to implement, stable, and economical especially with moving grids.

Adopting a Poisson-like approach, the following differential equation for a variable ϕ is solved:

(17.119)

subject to

(17.120)

The normal distance to the nearest wall is computed using the predicted value of $$ \phi $$ and its gradient as

(17.121)

While solving a turbulent flow problem, Eq. (17.119) is discretized on the grid network generated for solving the problem using the finite volume method and following the procedures described in Chap. 8. During the solution procedure, a converged solution for Eq. (17.119) is first obtained, from which the normal distances to the wall are computed, prior to solving the turbulent flow problem. Referring to Fig. 17.3, and recalling that the term gDiff f is defined as

(17.122)

the discretized form of Eq. (17.119) can be written as

(17.123)

where

(17.124)

Fig. 17.3

A two-dimensional control volume with its geometrical quantities

Moreover, the Dirichlet and Von Neumann boundary conditions described by Eq. (17.120) are treated as explained in Chap. 8.

Following the solution for Eq. (17.119), the normal distance to the wall at all cell centroids in the domain are calculated using Eq. (17.121) with the gradient calculated as detailed in Chap. 9.

17.10 Computational Pointers

OpenFOAM® [54] implements several LES and RANS turbulence models for both compressible and incompressible flows. The root directory for all models is denoted by “FOAM_SRC/turbulenceModels”. Incompressible turbulence models are located in the sub-directory “FOAM_SRC/turbulenceModels/incompressible” within which the three sub-sub-directories “LES” (refers to the large eddy simulation approach), “RAS” (refers to the Reynolds-averaged Navier-Stokes approach), and “turbulenceModel” reside. The first two sub-sub-directories “LES” and “RAS” define the special features of the LES and RAS models, respectively, while in “turbulenceModel” the abstract base classes of both incompressible RAS and LES models are defined. The base class defines a series of abstract virtual functions that have to be specified for any derived class as shown in Listing 17.1.

Listing 17.1

Script used to define virtual functions

The base class also defines the normal distance to the wall, which is a useful quantity for turbulence models that can be used with all derived classes. The statement used for that is given in Listing 17.2 as

Listing 17.2

Statement used to define the normal distance to the wall

To better understand the code structure that defines the OpenFOAM® turbulence models, in the following the k − ε model with the Spalding wall functions and the SST k – ω model are used as examples.

The model definition can be found in the directory “FOAM_SRC/turbulenceModels/incompressible/RAS” where all the RANS turbulence models are placed and defined. For the RANS models, OpenFOAM® defines an additional non virtual base class named RASModel (deriving the turbulenceModel class) from which all models are derived (Listing 17.3).

Listing 17.3

Script used to define the non virtual base class RASModel

This class is just a wrapper mainly for bounding the values of the effective viscosity and turbulence quantities, as well as a dictionary definition.

17.10.1 The k − ε Model

The “kEpsilon” class implements the standard version of the k − ε model given by Eqs. (17.25) and (17.26). It defines the necessary constants and set of variables used in the model, as shown in Listing 17.4.

Listing 17. 4

Script defining the k − ε model

It is selectable from the “RASProperties” dictionary with the name “kEpsilon” defined under the “TypeName” of the class as (Listing 17.5)

Listing 17.5

Statement used to select the k − ε model

Being derived from the base virtual class “turbulenceModel”, all its virtual base functions have to be defined as follows (Listing 17.6).

Listing 17.6

Statements used to define the effective stress tensor and the diffusion field in the momentum equation

The “divDevReff” function returns the diffusion contribution in the momentum equation including the Reynolds stress, i.e.,

(17.125)

In this case the type of data returned by the function (Listing 17.7) is in the form of an fvMatrix defined as

Listing 17.7

Implicit and explicit contributions of the Laplacian term

in which the Laplacian of the velocity field is split into an implicit and an explicit matrix contribution. It is important to mention that the divDevReff term depends only on the velocity gradient field and the total or effective viscosity (nuEff()). This means that OpenFOAM® implements the wall shear stress contribution by modifying only the turbulent viscosity at the wall; thus implementing Eq. (17.77).

The assembly and solution of the turbulence model equations are defined via the “correct()” member function as in Listing 17.8.

Listing 17.8

Assembly and solution of the turbulence model

Here OpenFOAM® first assembles and then solves the ε equation before the $$ k $$ equation, using the script in Listing 17.9 as

Listing 17.9

Assemble and solve the ε equation

where the G field defines the global production term previously defined in Eq. (17.28) as P k . Based on the wall functions approach, it is necessary before solving the ε equation, to modify the value of ε at all centroids of cells attached to the wall using Eqs. (17.81) and (17.83). In OpenFOAM® the values of ε and P k are altered at the wall by defining a special wall boundary condition for the field ε with the modification forced through the function “epsilon_.boundaryField().updateCoeffs();” with the dedicated boundary definition for the dissipation rate ε found under the directory “FOAM_SRC/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction”.

Based on the wall function model this class has to update the values of the two variables ε and P k . This operation is performed by the function “calculate” in which, after defining all necessary variables, a loop cycle changes the corresponding values (with G in Listing 17.10 corresponding to the P k production term). The “w” variable is just a weight factor to take into account boundary cells in contact with more than one wall (i.e., corners). For standard faces “w” has a value of one.

Listing 17.10

Calculating ε and modifying the production of turbulence kinetic energy in the near wall cells

It is important to note that while G or P k is a source term, ε is a field that is solved by a transport equation. To impose in a cell a value previously calculated, the matrix has to be manipulated at the right location, in order to return the correct value.Thus the class “epsilonWallFunctionFvPatchScalarField” is derived, as shown in Listing 17.11, from the class “fixedInternalValueFvPatchField” according to

Listing 17.11

Creating the class “epsilonWallFunctionFvPatchScalarField” from the class “fixedInternalValueFvPatchField”

with class “fixedInternalValueFvPatchField”, shown in Listing 17.12, being just a wrapper class containing a special function to manipulate the matrix by imposing the expected values of the variable in a list of cells.

Listing 17.12

The functionality of the “fixedInternalValueFvPatchField” class

This function is called form the “kEpsilon::correct()” class after assembling the matrix with “epsEqn().boundaryManipulate(epsilon_.boundaryField());”.

Once the ε equation is solved, OpenFOAM® proceeds to assembling and solving the k equation, as shown in Listing 17.13.

Listing 17.13

Assemble and solve the k equation

In this case no additional manipulation is required as the production term P k is already changed at the wall and the boundary condition for k is just a zero gradient (“zeroGradient”) type.

After calculating the k and ε values, the turbulent eddy viscosity v t (=μ t /ρ) is updated and then corrected at wall boundaries according to Eq. (17.77). This is accomplished using the following statements in Listing 17.14:

Listing 17.14

Updating the turbulent eddy viscosity at walls

The “volScalarField” nut (v t ) is defined in the constructor of the kEpsilon classshown in Listing 17.15 as

Listing 17.15

Script used to define the turbulent eddy viscosity

in which the function “autoCreateNut” is used. This function is defined in the file “backwardsCompatibilityWallFunctions.C”, which is placed in the directory “FOAM_SRC/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions”. The “autoCreateNut” acts in order to create the (v t ) object by reading the file and the related boundary types only if it is already present inside the working directory (Listing 17.16).

Listing 17.16

“IF” statement for checking the definition of the nut file

For the case when the file “nut” is not found, the standard Spalding wall function is applied using the boundary patch class definition “nutkWallFunctionFvPatchScalarField”, through the following statement (Listing 17.17):

Listing 17.17

Application of the standard Spalding wall function

The class “nutkWallFunctionFvPatchScalarField” described in Listing 17.18 is located in the “FOAM_SRC/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions” directory and inherits a base class named “nutWallFunctionFvPatchScalarField”, i.e.,

Listing 17.18

Class definition

The “nutWallFunctionFvPatchScalarField” in Listing 17.19 is a base class that wraps the changing of the boundary value of the eddy viscosity “nut” (v t ) by defining the related “updateCoeffs” function as

Listing 17.19

The updateCoeffs() function definition

where the “calcNut” function is defined as pure virtual and it has to be delineated from the derived class. Based on that the derived class “nutkWallFunctionFvPatchScalarField” implements the “calcNut” function according to Spalding assumption and Eq. (17.77) as in Listing 17.20.

Listing 17.20

Calculate eddy viscosity at the wall according to Spalding wall function

Once the turbulent eddy viscosity is updated based on the wall function value the momentum shear stress is then correctly evaluated.

17.10.2 The SST k – ω Model

The “kOmegaSST” class implements the version of the SST k − ω model described by Eqs. (17.38) through (17.49). The set of variables and constants used in the model are defined by the script shown in Listing 17.21.

Listing 17.21

Script defining the SST k – ω  model

Additional private member functions (blend, alphaK, alphaOmega, etc.) are now defined in order to represent the blended coefficients appearing in Eq. (17.39). Functions F1 and F2 describe the variables given by Eqs. (17.41) and (17.47), respectively. Function F3 does not appear in Menter’s original model and is a modification for rough walls introduced by Hellsten [55].

As shown in Listing 17.22, the model is selectable from the “RASProperties” dictionary with the name “kOmegaSST” defined under the “TypeName” of the class as

Listing 17.22

Statement used to select the SST k – ω model

The kOmegaSST class is derived from the base virtual class “turbulenceModel”, and as such all its virtual base functions are specialized accordingly (Listing 17.23).

Listing 17.23

Specialization of the pure virtual functions defined in the base class “RASModel”

The implementation of the model is detailed in “FOAM_SRC/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.C”. As in the kEpsilon class the correct function solves the full set of equations of the SST turbulence model. First the ω equation is setup and solved using the script shown in Listing 17.24.

Listing 17.24

Assemble and solve the ω equation

In the script, the G field represents the production term P k defined in Eq. (17.28), while the CDkOmega and F1 fields are evaluated based on Eqs. (17.41), (17.42), and (17.47).

As in the kEpsilon class the values of ω and P k are modified at the wall following the wall functions approach by defining a wall boundary condition class for ω. Modifications to the field are then enforced through the function “omega_.boundaryField().updateCoeffs();”. The boundary definition for the eddy frequency ω can be found under the directory “FOAM_SRC/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction”.

Based on the wall functions model, this class has to update the values of the two variables ω and P k . This operation is performed, as shown in Listing 17.25, by the usual “calculate” function using Eqs. (17.81), (17.99) and (17.100) (with G corresponding to the P k production term).

Listing 17.25

Calculating ω and modifying the production of turbulence kinetic energy in the near wall cells

To impose the previously calculated cell value, the matrix has to be manipulated following the same procedure used with the “kEpsilon” model. Once the ω equation is solved, OpenFOAM® proceeds to assembling and solving the k equation, as shown in Listing 17.26.

Listing 17.26

Assemble and solve the k equation

In this case no additional manipulation is required as the production term P k is already modified at the wall and the boundary condition for k is just a zero gradient (“zeroGradient”) type.

Once the k and ω values are calculated the turbulent eddy viscosity v t (=μ t /ρ) is updated using the script in Listing 17.27, which is in accordance with Eq. (17.46).

Listing 17.27

Updating the turbulent eddy viscosity

The Menter reliability constraint is applied to the eddy viscosity where the constant b1_ takes the value of 1.0, while the F23 function, described in Listing 17.28, returns by default the proper F2 function defined by Eq. (17.47).

Listing 17.28

The F23 function definition

Finally the eddy viscosity is corrected at wall boundaries according to Eq. (17.77) using the same procedure as in the kEspilon class in which the Spalding wall function is applied by the class “nutkWallFunctionFvPatchScalarField”.

17.10.3 simpleFoamTurbulent

The simpleFoamTurbulent solver is an extension, for turbulent flow simulations, of the simpleFoamImproved solver described in Chap. 15. As previously described, turbulence affects the diffusion terms of the transport equations. Its effects are embodied into the equations through the effective viscosity, which is the sum of both laminar and eddy viscosities.

In order to include turbulence in the OpenFOAM® solver, the virtual base class RASModel is invoked and few modifications are introduced. The first one is to substitute the constant laminar transport properties with the variable turbulent ones through the turbulence model. Therefore in the “createFields.H” file, the object turbulence of type RASModel is instantiated, as shown in Listing 17.29.

Listing 17.29

Turbulence model definition

For the definition of the RASModel, it is necessary to activate the singlePhaseTransportModel class that defines the general transport model for the laminar viscosity (from dictionary it could be set as constant or as function of temperature like in the Sutherland’s model), the velocity, and the mass flux. As described earlier, these quantities are necessary to define the transport equations of the turbulent quantities. To be noticed in Listing 17.29 is the definition of object turbulence as “autoPtr”, which basically can be treated as a standard pointer in C⁺⁺.

The second main modification, as depicted in Listing 17.30, is to the momentum equation where diffusion is now computed using the divDevReff(U) term previously described.

Listing 17.30

Momentum equation detail

The last main modification displayed in Listing 17.31 is in the main solver file shown below.

Listing 17.31

Main file modification: turbulence model solution

The addition of the statement turbulence->correct() activates, each time it is called, the solution of the turbulence model equations allowing the calculation of the eddy viscosity, which is used in the momentum equations.

17.11 Closure

The extra step needed to model incompressible turbulent flows was introduced. The k − ε, k − ω, and some of their variants were discussed. Modeling of the near wall region using wall functions was detailed. This concludes the developments intended to be discussed in this book. The next chapter will discuss the implementation of boundary conditions in OpenFOAM® and uFVM.

17.12 Exercises

Exercise 1

Given the following turbulent intensities and integral length scales, calculate the corresponding k – ω − ε values (Table 17.1):

Table 17.1

Data for exercise 1

I

0.01

0.05

0.1

0.25

0.5

ℓ

0.0001

0.1

0.2

1

10

k

ε

ω

Exercise 2

Given the following turbulent intensities and viscosity ratios calculate the corresponding k – ω − ε values (Table 17.2):

Table 17.2

Data for exercise 2

I

0.01

0.05

0.1

0.25

0.5

μ t /μ

0.1

1

10

100

1000

k

ε

ω

Exercise 3

Modify the standard k − ε turbulence model described above to include the realizability constraint described in Eqs. (17.29–17.31).

Exercise 4

Formulate the realizability constraint of the standard k − ω turbulence model.

Exercise 5

Starting with the BSL k − ω model, show that, if the F ₁ function is identically one, the ω-equation corresponds, with minor simplifications, to the standard ε equation of the k − ε turbulence model.

Exercise 6

Using a Newton-Raphson linearization (i.e., $$ y(x) \approx y(0) + xy^{\prime}(x) $$), formulate the diagonal and the source term coefficients of Eq. (17.63).

Exercise 7

Formulate Eqs. (17.83) and (17.84) based on turbulent dimensionless quantities, i.e.,

Exercise 8

Develop an OpenFOAM® application that implements normal distance to the wall using Eqs. (17.119), (17.120), (17.121).

Exercise 9

Experiments in roughened surfaces indicate that near rough walls the classical logarithmic law of the wall has a different intercept. This is due to a higher wall shear stress, which shifts the logarithmic velocity profile downward. With the assumption that the following formula is applicable:

where $$ \Delta B = \frac{1}{\kappa }Ln(1 + h_{s}^{+ } ) $$ ($$ h_{s}^{+ } $$ is the equivalent sand grain roughness), find an equivalent $$ d_{eff}^{+ } $$ formulation, valid for both smooth and rough walls, allowing the logarithmic law of the wall to be re-expressed in its classical form, i.e.,

Exercise 10 (OpenFOAM®)

Using the Doxygen documentation [56], list all derived classes of the base class RASModel for incompressible flows (i.e., turbulence models available in OpenFOAM®).

Exercise 11 (OpenFOAM®)

Identify the turbulent quantities that are resolved in each incompressible turbulence model defined in Exercise 10.

Exercise 12 (OpenFOAM®)

Using the Doxygen documentation, list all derived classes of the base class nutWallFunctionFvPatchScalarField.

Exercise 13 (OpenFOAM®)

The base class nutWallFunctionFvPatchScalarField defines an additional virtual base function virtual tmp<scalarField>yPlus () const = 0. Describe the function definition for each of the derived classes, commenting on the differences.

Exercise 14 (OpenFOAM®)

Compare the implementation in “FOAM_SRC/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction” with the Low Reynolds number models formulation given by Eq. (17.98).

References

1.

Tennekes H, Lumley JL (1972) A first course in turbulence. MIT Press, Cambridge. ISBN 978-0-262-20019-6

2.

Kolmogorov AN (1941) The local structure of turbulence in incompressible viscous fluids at very large Reynolds numbers. Doklady AN SSSR 30:299–303

3.

Kolmogorov AN (1941) Dissipation of energy in isotropic turbulence. Dokl Akad Nauk SSSR 32:19–21.é

4.

Moser RD, Kim J, Mansour NN (1999) Direct numerical simulation of turbulent channel flow up to Re τ = 590. Phys Fluids 11(4):943–945MATHCrossRef

5.

Scardovelli R, Zaleski S (1999) Direct numerical simulation of free-surface and interfacial flow. Ann Rev Fluid Mech. 31:567–603

6.

Le H, Moin P, Kim J (1997) Direct numerical simulation of turbulent flow over a backward-facing step. J Fluid Mech 330:349–374MATHCrossRef

7.

Choi H, Moin P, Kim J (1993) Direct numerical simulation of turbulent flow over Riblets. J Fluid Mech 255:503–539MATHMathSciNetCrossRef

8.

Leonard A (1974) Energy cascade in large-eddy simulations of turbulent fluid flows. Adv Geophys A 18:237–248CrossRef

9.

Sagaut P (2006) Large eddy simulation for incompressible flows-an introduction. Springer, BerlinMATH

10.

Ferziger JH (1995) Large eddy simulation. In: Hussaini MY, Gatski T (eds) Simulation and modeling of turbulent flows. Cambridge University Press, New York

11.

Nieuwstadt FTM, Mason PJ, Moeng C-H, Schuman U (1991) Large eddy simulation of the convective boundary layer: a comparison of four computer codes. In: Durst F et al (eds) Turbulent shear flows, 8th edn. Springer, Berlin

12.

Reynolds O (1895) On the dynamical theory of incompressible viscous fluids and the determination of the criterion. Philos Trans Royal Soc London A 186:123–164MATHCrossRef

13.

Favre A (1965) Equations des Gas Turbulents Compressibles. Journal de Mecanique 4(3):361–390

14.

Boussinesq J (1877) Essai sur la théorie des eaux courantes. Mémoires présentés par divers savants à l’Académie des Sciences 23(1):1–680

15.

Schlichting H (1968) Boundary-layer theory, 6th edn. Chapter XIX. McGraw Hill

16.

Schmitt FG (2007) About Boussinesq’s turbulent viscosity hypothesis: historical remarks and a direct evaluation of its validity. Comptes Rendus Mécanique 335(9 and 10):617–627

17.

Prandtl L (1925) Uber die ausgebildete Turbulenz. ZAMM 5:136–139MATH

18.

Baldwin BS, Lomax H (1978) Thin-Layer approximation and algebraic model for separated turbulent flows. AIAA Paper, Huntsville, pp 78–257

19.

Cebeci T, Smith AMO (1974) Analysis of turbulent boundary layers. Ser Appl Math Mech, vol XV, Academic Press, Waltham

20.

Baldwin BS, Barth TJ (1990) A one-equation turbulence transport model for high reynolds number wall-bounded flows. NASA TM-102847

21.

Goldberg UC (1991) Derivation and testing of a one-equation model based on two time scales. AIAA J 29(8):1337–1340CrossRef

22.

Spalart PR, Allmaras SR (1992) A one-equation turbulence model for aerodynamic flows. AIAA Paper, Reno, pp 92–439

23.

Jones WP, Launder BE (1972) The prediction of laminarization with a two-equation model of turbulence. Int J Heat Mass Transf 15:301–314CrossRef

24.

Launder BE, Sharma BI (1974) Application of the energy dissipation model of turbulence to the calculation of flow near a spinning disk. Lett Heat Mass Transfer 1(2):131–138CrossRef

25.

Chien K-Y (1982) Predictions of channel and boundary-layer flows with a low-reynolds-number turbulence model. AIAA J 20(1):33–38MATHMathSciNetCrossRef

26.

Myong HK, Kasagi N (1990) A new approach to the improvement of k-ε turbulence model for wall-bounded shear flows. JSME Int J 33:63–72

27.

Kolmogorov AN (1942) Equations of turbulent motion of an incompressible fluid. Izvestia Acad Sci USSR Phys 6(1 and 2):56–58

28.

Wilcox D (1988) Reassessment of the scale-determining equation for advanced turbulence models. AIAA J 26(11):1299–1310MATHMathSciNetCrossRef

29.

Wilcox DC (1998) Turbulence modeling for CFD, 2nd edn. DCW Industries, US

30.

Menter FR (1992) Influence of freestream values on k − ω turbulence model predictions. AIAA J 30(6):1657–1659CrossRef

31.

Menter FR (1993) Zonal two-equation k − ω turbulence model for aerodynamic flows. AIAA Paper, Orlando, pp 1993–2906

32.

Menter F (1994) Two-equation eddy-viscosity turbulence models for engineering applications. AIAA J 32(8):1598–1605CrossRef

33.

Menter FR, Kuntz M, Langtry R (2003) Ten years of industrial experience with the SST turbulence model, 4th edn. Turbulence, Heat and Mass Transfer, Antalya, pp 73–86

34.

Menter FR, Carregal Ferreira J, Esch T, Konno B (2003) The SST turbulence model with improved wall treatment for heat transfer predictions in gas turbines. In: Proceedings of the international gas turbine congress, Tokyo, IGTC2003-TS-059

35.

Menter FR (2009) Review of the shear-stress transport turbulence model experience from an industrial perspective. Int J Comput Fluid Dyn 23(4):305–316MATHCrossRef

36.

Daky BJ, Harlow FH (1970) Transport equations in turbulence. Phys Fluids 13:2634–2649CrossRef

37.

Fu S, Launder BE, Tselepidakis DP (1987) Accommodating the effects of high strain rates in modelling the pressure-strain correlation. Report no. TFD/87/5, Mechanical Engineering Department, Manchester Institute of Science and Technology, England

38.

Gibson MM, Launder BE (1986) Ground effects on pressure fluctuations in the atmospheric boundary layer. J Fluid Mech 86(Pt. 3):491–511

39.

Gibson MM, Younis BA (1986) Calculation of swirling jets with a reynolds stress closure. Phys Fluids 29:38–48CrossRef

40.

Wilcox DC, Rubesin MW (1980) Progress in turbulence modeling for complex flow fields including effects of compressibility. NASA TP-1517

41.

Wilcox DC (1988) Multiscale model for turbulent flows. AIAA J 26(11):1311–1320MathSciNetCrossRef

42.

Patel VC, Rodi W, Scheuerer G (1985) Turbulence models for near-wall and low reynolds number flows: a review. AIAA J 23(9):1308–1319MathSciNetCrossRef

43.

Medic G, Durbin PA (2002) Toward improved prediction of heat transfer on turbine blades. ASME J Turbomach 124(2):187–192CrossRef

44.

Sahay A, Sreenivasan KR (1999) The wall-normal position in pipe and channel flows at which viscous and turbulent shear stresses are equal. Phys Fluids 11(10):3186–3188MATHCrossRef

45.

Bredberg J (2000) On the wall boundary condition for turbulence models. Department of Thermo and Fluid Dynamics, Chalmers University of Technology, Internal report 00/4, Goteborg

46.

Launder BE, Spalding DB (1974) The numerical computation of turbulent flows. Comput Methods Appl Mech Eng 3:269–289MATHCrossRef

47.

Grotjans H, Menter F(1998) Wall function for general application cfd codes. In: Computational fluid dynamics 1998, Proceedings fourth European CFD Conference ECCOMAS, Wiley, Chichester

48.

Menter F, Esch T (2001) Elements of industrial heat transfer prediction. In: Proceedings 16th Brazilian congress of mechanical engineering (COBEM), pp 117–127

49.

Kader BA (1981) Temperature and concentration profiles in fully turbulent boundary layers. Int J Heat Mass Transf 24:1541–1544CrossRef

50.

Tucker PG (2003) Differential equation-based wall distance computation for DES and RANS. J Comput Phys 190:229–248MATHCrossRef

51.

Sethian JA (1999) Fast marching methods. SIAM Rev 41(2):199–235MATHMathSciNetCrossRef

52.

Tucker PG, Rumsey CL, Spalart PR, Bartels RE, Biedron RT (2004) Computations of wall distances based on differential equations. AIAA Paper 2004–2232

53.

Xu J-L, Yan C, Fan J-J (2011) Computations of wall distances by solving a transport equation. Appl Math Mech 32(2):141–150MathSciNetCrossRef

54.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

55.

Hellsten A (1998) Some improvements in menter’s k-omega-SST turbulence model. In: 29th AIAA fluid dynamics conference, AIAA-98-2554

56.

OpenFOAM Doxygen (2015) Version 2.3.x. http://​www.​openfoam.​org/​docs/​cpp/​

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_18

18. Boundary Conditions in OpenFOAM® and uFVM

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

This chapter reviews the implementation of boundary conditions in OpenFOAM® and uFVM. Details on the data structure needed for their implementation are presented along with information on how to add new boundary conditions. The procedure is illustrated through the implementation of the no-slip wall boundary condition. This is shown to differ from the Dirichlet type currently implemented in OpenFOAM®.

18.1 Boundary Conditions in OpenFOAM®

Each boundary condition has a physical meaning described mathematically via an equation, which in the context of a numerical method has to be translated into an algebraic relation. An inlet boundary condition for instance, describes a known flow behavior where velocity and pressure satisfy specified physical conditions expressed using proper mathematical equations. These include a Dirichlet and a Neumann condition, which should be defined in order to connect the mathematical model with the boundary conditions of the problem. The implementation of these conditions will affect the mathematical operator or term to which they apply (i.e., divergence, laplacian, gradient, etc.).

In OpenFOAM® [1] almost all definitions of boundary conditions are stored in the following directory (Listing 18.1):

Listing 18.1

OpenFOAM® directory where boundary condition definitions are stored

with the main implemented types of boundary conditions stored in the sub-directories listed in Listing 18.2.

Listing 18.2

Sub-directories where the main types of boundary conditions are implemented

A brief description of these sub-directories is given in what follows.

The fvPatchField directory contains the general class definition of a boundary condition, which represents the base class. This class defines the main functions and data structures that will be used and will be inherited by the genuine classes.

The basic directory contains the basic mathematically defined boundary conditions. These are the Dirichlet type (fixedValue), the Neuman type (zeroGradient and fixedGradient), and the Robin type (mixed) boundary conditions. One additional entry included in basic is the coupled boundary condition that implements a patch to patch type condition, i.e., coupling two boundary patches together (coupled boundaries).

The constraint directory contains geometric type boundary conditions that derive from the coupled boundary class. An example is the periodicity boundary condition depicted schematically in Fig. 18.1. In this case each cell is related to the cell of the corresponding patch allowing the boundary cells to be treated as internal ones.

Fig. 18.1

A schematic of a periodic boundary condition

Finally the derived directory includes all boundary conditions that are derived from the basic Dirichlet, Neumann, and Robin boundary conditions. These derived boundary conditions are simply specializations of the basic types.

18.2 Boundary Condition Customization

To write a new boundary condition it is essential to understand the role of five main functions, namely, updateCoeffs, valueInternalCoeffs, valueBoundaryCoeffs, gradientInternalCoeffs, and gradientBoundaryCoeffs.

updateCoeffs: This member function is responsible for the explicit update of the values at the boundary face centers. The function is called whenever the patch field values need to be updated iteratively. For example in the totalTemperatureFvPatchScalarField class, updateCoeffs is used to compute, as shown in Listing 18.3, the static temperature from the specified Total Temperature value according to the relation $$ T = T_{0} - 0.5(\gamma - 1)U^{2} /(\gamma R) $$.

Listing 18.3

Script used to iteratively update the static temperature from total temperature using the updateCoeffs function

In Listing 18.3 the operator == assigns the computed value to the static temperature.

Another example is setting a mean value to an entire patch. The idea is to impose an average value at all faces of a boundary patch based on the average of the values at the centroids of their associated boundary cells and a specified mean value. The required updateCoeffs function is written as shown in Listing 18.4.

Listing 18.4

Another example of using the function updateCoeffs to update boundary values

Note that the function in this case is a template. Therefore it can be used in conjunction with a variety of types such as scalars, vectors, or tensors.

With updateCoeffs() the values at the face centroids are set explicitly as for a Dirichlet condition. However the other functions, valueInternalCoeffs, valueBoundaryCoeffs, gradientInternalCoeffs, and gradientBoundaryCoeffs are used to linearize the boundary condition in order to complement the updateCoeffs() function. The valueInternalCoeffs and valueBoundaryCoeffs are generally used to linearize the boundary condition for a divergence operator since for that operator the value at the patch faces is needed. On the other hand, the gradientInternalCoeffs and gradientBoundaryCoeffs are used to linearize the boundary condition for a laplace type operator since for that operator the gradient at the patch faces is needed. This is summarized in Table 18.1.

Table 18.1

A summary of the coefficients used to linearize boundary conditions

Diagonal Coeff

Source term

Divergence

valueInternalCoeffs

valueBoundaryCoeffs

Laplacian

gradientInternalCoeffs

gradientBoundaryCoeffs

To clarify the above, the implementations of two boundary conditions are considered. The first is the Neuman (zeroFlux) boundary condition, while the second is the Dirichlet (specifiedValue) boundary condition.

For a Neumann (zeroFlux) boundary condition and assuming an orthogonal mesh, the value of the boundary patch is equal to the value of the boundary element since the normal gradient should be equal to zero. For the divergence term where the boundary patch value will be needed, the specified value at the boundary patch is written in term of the valueInternalCoeffs and valueBoundaryCoeffs, which represent the linearization of the boundary element value and its non-linearizable part, respectively. For example, the boundary value of a zero gradient boundary condition can be written as

(18.1)

The syntax used to implement the zeroFlux condition for the divergence operator is shown in Listing 18.5.

Listing 18.5

Implementation of the zeroFlux boundary condition for the divergence operator

For the laplacian operator, the gradient at the boundary is needed. In this case the gradient at the boundary patch is set to zero (zeroFlux). This is done through the use of the gradient linearization, which is written as

(18.2)

where now the gradientInternalCoeffs is the linearized coefficient and gradientBoundaryCoeffs is the non-linearized component of the gradient as shown in Listing 18.6.

Listing 18.6

Implementation of the zeroFlux boundary condition for the laplacian operator

A summary of the value of the coefficients used to implement a zeroFlux boundary condition is given in Table 18.2.

Table 18.2

A summary of the coefficients for a zeroFlux boundary condition

Neumann (zero order)

Diagonal Coeff

Source term

Divergence

Value(1)

0

Laplacian

0

0

In the above, the value at the boundary is set equal to the value of the boundary element since a zero flux condition is specified.

For a Dirichlet boundary condition, the contribution to the matrix of coefficients will be just a source term on the right hand side of the equations. In this case the boundary condition does not alter the diagonal. The valueInternalCoeffs and valueBoundaryCoeffs are defined inside OpenFOAM® as

(18.3)

For the laplacian operator, the gradient at the boundary is based on the Dirichlet value. In this case the gradient at the boundary patch is set again through the use of the gradient linearization, which is written as

A summary of the coefficient values is given in Table 18.3, while the template code is shown in Listing 18.7.

Table 18.3

A summary of the coefficients for a Dirichlet boundary condition

Dirichlet

Diagonal Coeff

Source term

Divergence

0

Boundary value

Laplacian

Delta

Boundary value and delta

Listing 18.7

Syntax used for the implementation of the Dirichlet boundary condition

18.3 Development of a New BC: No Slip Wall Condition

The task is to define a new boundary condition type for the proper implementation of the no slip condition in the context of the finite volume discretization in OpenFOAM® (Fig. 18.2).

Fig. 18.2

No-slip wall shear stress

The no slip condition is a fundamental boundary condition in solving flow problems. According to Newton’s law, the shear stress experienced by a viscous fluid flowing past a wall is proportional to the normal gradient of the velocity parallel to the wall and is expressed mathematically as

(18.4)

where C refers to values at the centroid of the boundary cell. This equation suggests that the no slip condition is anisotropic because it is function only of the velocity component parallel to the wall and the normal distance to the wall. For the case when the wall is aligned with the x-axis, only the x-component of velocity is expected to affect the shear stress value. In fact from Eq. (18.4) the shear stress equation becomes

(18.5)

where it is evident that only the diagonal coefficient of the x-component of velocity has to be injected into the matrix.

A common simplification for this boundary condition, used in OpenFOAM®, is its treatment as a Dirichlet boundary condition, i.e., a fixedValue (0 0 0) boundary condition.

Using a Dirichlet condition for the implementation of the no-slip condition at a wall introduces an important error. This error is due to treating the shear stress distribution as isotropic with its value influenced by the velocity component (of the internal cells) normal to the wall. In fact using a Dirichlet boundary condition for the case when the wall is parallel to the x-velocity component, results in a shear stress evaluated as

(18.6)

which, when compared with Eq. (18.2), clearly demonstrates the unphysical dependence of the wall shear stress on the y-component of velocity.

In the following, the proper implementation of the no slip wall condition in OpenFOAM® is described. The suggested implementation should always be used instead of the simplified assumption of a Dirichlet boundary condition for momentum discretization at a no-slip wall.

As stated above, the definition of a new boundary condition necessitates redefining the proper functions. A good starting point is to use an existing boundary class, copying it, and modifying it with the new algorithms. For this purpose, the fixedValue class can be used and altered for vector type. The .H file defining the new virtual no slip wall class is depicted in Listing 18.8.

Listing 18.8

Synopsis of the .H file for the declaration of the noSlipWallFvPatchVectorField class

As noticed, just the gradientCoeffs function is redefined, since in the fixedValue class the valueCoeffs and the updateCoeffs functions are already correctly implemented.

Once the declarations of the functions are ready, implementation proceeds with the modifications to the .C file. The starting point is Eq. (18.1) but now written in three dimensions as

(18.7)

Equation (18.7) indicates that all elements in the matrix have implicit contributions because they depend on the internal cell value and have to be implemented with the gradientInternalCoeffs. The other term is the tangential component of the wall velocity and it depends on the face value only. In this case it is necessary to be described through the function gradientBoundaryCoeffs. Moreover, a closer look at the implicit contribution suggests storing its mixed terms on the right hand side of the equation to be treated explicitly since the momentum equations are solved in a segregated fashion. Thus Eq. (18.7) is rewritten as

(18.8)

Based on the above formulation, the gradienInternalCoeffs function reads as shown in Listing 18.9.

Listing 18.9

Script used for calculating the implicit contribution

On the other hand, the calculation of the gradientBoundaryCoeffs is as shown in Listing 18.10.

Listing 18.10

Script used for calculating the explicit contribution

The new boundary condition can now be used with any wall by just defining the patch type as noSlipWall, as described in Listing 18.11.

Listing 18.11

Script needed to use the no-slip boundary condition at runtime

18.4 The No-Slip Boundary Condition in uFVM

Adding a new boundary condition in uFVM requires that the boundary be implemented for each term to which it can be applied, thus is not as modular as in OpenFOAM®. Still it can be quite straightforward as demonstrated for the no-slip boundary condition.

It is important to emphasize that the no-slip boundary condition is somewhat a hybrid condition where a flux (the shear stress) has to be computed while ensuring that the boundary velocities are set to specified values, in this case zero. So it relates somewhat to the Dirichlet and Neumann conditions.

In uFVM information about boundary conditions are stored in a patch-based structure composed of the following four arrays:

1.

thePatchFlux.FLUXC1f : the linearization coefficient for the owner cell

2.

thePatchFlux.FLUXC2f : the linearization coefficient for the neighbor cell

3.

thePatchFlux.FLUXVf: the non-linearized part

4.

thePatchFlux.FLUXTf: the total flux at the face

in such a manner that the boundary flux is expressed as

(18.9)

Equation (18.9) shows how the total flux at any internal face is linearized in terms of the owner and neighbor elements sharing the face, except that for a patch the neighbor node is basically the boundary node. For a boundary face, where there is no neighbor element defined, thePatchFlux.FLUXC2f is always set to zero.

For the no slip condition where the total flux (i.e., the shear stress) depends on the change of the velocity component parallel to the wall, the expressions of the various contributions become

(18.10)

where F c is the actual shear flux computed at the patch wall faces as

(18.11)

The complete code for the implementation of the boundary condition is shown in Listing 18.12.

Listing 18.12

Script used for the implementation of the no-slip boundary condition in uFVM

18.5 Closure

The chapter discussed the implementation of boundary conditions in OpenFOAM®. It also presented the needed steps for implementing new boundary conditions in OpenFOAM® by detailing the various required stages for properly adding a no-slip boundary condition. A brief discussion of boundary conditions in uFVM was also presented. The next chapter is devoted to detailing the steps needed to solve a turbulent flow problem in OpenFOAM®.

Reference

1.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_19

19. An OpenFOAM® Turbulent Flow Application

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

Abstract

The OpenFOAM® solvers and boundary conditions developed in previous chapters are used here to solve a small scale turbulent incompressible flow problem. Details on the case structure, mesh, and solver setup are presented along with information on monitoring convergence and post processing results.

19.1 Introduction

The design of a car body is a very demanding task that necessitates finding a compromise between the stylistic constraint of the brand and consumer taste on one hand, and the engineering requirements of efficient aerodynamics for improved fuel economy on the other. The use of a CFD tool in this situation is critical, especially in investigating the aerodynamic forces, the interplay of viscous flow effects and turbulent boundary layer, the sensitivity of the flow around the vehicle to changes in its shape, and finally the drag coefficient of the car under various operating conditions.

In this chapter the simpleFoamTurbulent solver and the boundary conditions developed and implemented in previous chapters are used to analyze the flow around a well investigated test case, namely the Ahmed bluff body.

19.2 The Ahmed Bluff Body

In automotive applications, the major factor contributing to drag is the wake that develops behind the vehicle, with its prediction representing a difficult task in CFD. This is so because flow separation in turbulent flows is still a challenge to simulate numerically. Nonetheless determining the size of the flow separation zone greatly influences the predicted drag force acting on the body. Thus, accurate simulation of the induced vortex flow and of the separation process is essential for correct predictions of aerodynamic efficiency.

Current automobile designs have many complex geometrical features that make them a challenge to model and/or investigate experimentally. Thus for the limited investigation considered here, the Ahmed bluff body [1, 2], which is schematically depicted in Fig. 19.1, is chosen. Figure 19.1a shows the side, front, and top views from which dimensions can be inferred, while Fig. 19.1b presents a three dimensional visualization of the body. Even though it represents simple geometry, Ahmed body allows for a three-dimensional region of separated flow to be developed and different flow phenomena to be studied and compared to experimental data.

Fig. 19.1

a Side, front, and top views of Ahmed body, b a three dimensional visualization of Ahmed body geometry

The Ahmed body is a well known configuration and is widely used as benchmark. The slant geometry at its back end generates counter-rotating vortices at the side edges, whose strength is mainly determined by the base slant angle. It comes in two configurations differing in the slant angle value (25° and 35°). In this simulation the configuration with a 25° slant angle is considered.

19.3 Domain Discretization

The computational domain is depicted in Fig. 19.2 with a symmetry condition imposed along the mid section of the Ahmed body shape. Symmetry is exploited to reduce the computational domain and to mitigate the transient flow behavior expected to develop because of vortex shedding at the body’s rear end. This should also enhance numerical stability.

Fig. 19.2

Computational domain for Ahmed body

Inflow and outflow boundary conditions are placed far from the body to minimize any unwanted interaction with the main flow region, especially between the outlet and the flow at the rear end of the body.

The mesh is generated by snappyHexMesh, a utility that is part of the OpenFOAM® [3] package. snappyHexMesh generates three dimensional meshes containing hexahedra (hex) and split-hexahedra (split-hex) elements generated automatically from triangulated surface geometry in the Stereolithography (STL) format. The mesh gradually conforms to the surface by iteratively refining a starting mesh and morphing the resulting split-hex mesh to the surface. An optional phase will shrink back the resulting mesh and insert cell layers. The specification of mesh refinement level is very flexible and the surface handling is robust with a pre-specified final mesh quality. It runs in parallel with a load balancing step at every iteration [4].

It is beyond the purpose of this book to give a detailed introduction of the snappyHexMesh application but a commented setup file can be found in the case directory “Ahmed_body/system/snappyHexMeshDict”. Listing 19.1 shows an extract of the file.

Listing 19.1

An extract of the snappyHexMeshDict file

The mesh is generated by executing, from the case directory, the following commands in the shown sequence:

blockMesh—dict system/blockMeshDict this defines the general computational domain within which the snappyHexMesh will operate, the domain should have within its volume the STL geometry.

snappyHexMesh snappyHexMesh generates the mesh in three phases with the result of each phase written to a folder (1/2/ and 3/).

mv 3/polyMesh constant/ this moves the final mesh generated by snappyHexMesh into the constant directory to be used for computing the solution.

createPatch—overwrite this deletes any empty patches.

The body fitted grid is composed of about 800,000 polyhedral cells mostly located in two regions around the car body. This allows for a good resolution of the wake region while keeping low the number of elements used in the computational domain. Details of the grid generated around the body is shown in Fig. 19.3.

Fig. 19.3

Grid details around Ahmed body

Clustering of mesh elements in the region of interest is a common practice as it reduces the computational cost while properly resolving the important features of the flow.

The generated mesh is fully unstructured and uses polyhedral elements with up to 15 faces. The quality of the mesh is best evaluated using checkMesh, the output of such an operation is shown in Listing 19.2.

Listing 19.2

Grid quality check and details

The physical boundary conditions are set in the boundary file located in the “Ahmed_body/constant/polyMesh/” directory. This is displayed in Listing 19.3.

Listing 19.3

Script used to set the physical boundary conditions

The patches inlet and outlet are defined as type patch, while cp is set as a wall, rather than a symmetry plane. In order to reduce the complexity of resolving the flow, a slip boundary condition will be used for the cp patch. The “ahmed_body*” patches that represent the car body are defined as “wall”, while the remaining patches define the external domain.

19.3.1 Initial and Boundary Conditions

The 0 directory must contain the following four basic files for a turbulent incompressible flow simulation: the velocity U, the pressure p, and for the kEpsilon turbulence model, the turbulent kinetic energy k, and the dissipation rate ε.

The file U defines the boundary conditions for the velocity (Listing 19.4).

Listing 19.4

Script of the ∪ file

The new noSlipWall boundary condition is employed to impose the no slip condition at the walls including the body car and the floor. The fluid velocity at inlet is set at 40 m/s. Along the cp plane, a slip wall boundary condition is used where the viscous forces are set to zero to mimic a symmetry plane (the slight geometric error due to meshing on patch cp does not allow the direct use of a symmetryPlane boundary condition).

The zeroGradient pressure boundary condition uses a zero order extrapolation to compute the pressure at the boundary. At the outlet, a Dirichlet boundary condition is applied in order to set a reference pressure (Listing 19.5).

Listing 19.5

Script of the p file

For the kEpsilon model, the turbulent intensity and integral length scale are set at the inlet boundary, while the standard wall functions are employed along all the walls automatically (Chap. 17). The k file is shown in Listing (19.6) and the epsilon file in Listing (19.7).

Listing 19.6

Script of the k file

Listing 19.7

Script of the epsilon file

19.3.2 Systems Files

The controlDict file (Listing 19.8) is configured to perform 500 SIMPLE iterations. Further, in order to use the new noSlipWall boundary condition for the velocity, the corresponding library has to be included together with the proper libraries for inlet turbulence boundary conditions. These are set using the libs declaration. A specific run-time post processing configuration is also included to monitor iteratively variations in the lift and drag coefficients, which are set using the functions declaration. Usually for external aerodynamic applications it is more convenient to monitor loads or forces on the body, rather than the level of residuals, for checking convergence.

Listing 19.8

Script of the controlDict file

Linear solvers specifications and relaxation factors are configured in the fvSolution file displayed in Listing 19.9. Here preconditioned conjugate gradient methods with incomplete factorization pre-conditioners are chosen for all equations. For the pressure correction equation (pp), a symmetric matrix solver is specified due to the laplacian nature of the equation. It is worth mentioning that with a pressure correction formulation there is no need for non-orthogonal correction iterations.

Listing 19.9

Script of the fvSolution file

Spatial discretization settings are configured in the fvSchemes file depicted in Listing 19.10. For this simulation a first order upwind discretization for convection, a Gaussian method for gradient reconstruction, and a linear profile for variable face interpolation are used.

Listing 19.10

fvSchemes file details

19.3.3 Running the Solver

At the start of the run, the solver provides information about equation residuals and force coefficients (Listing 19.11). Based on the controlDict setup, force coefficients are also written in the file Ahmed_body/postProcessing/forceCoeffs1/0/forceCoeffs.dat that can be used for checking the convergence history.

Listing 19.11

Solver verbosity

It is worth noting that for the pressure correction equation the residual at any iteration is always 1, which is due to the way OpenFOAM® normalizes residuals (Check the computational pointers in Chap. 10).

Figure 19.4a shows the convergence history plots of the residuals of the momentum equations, while Fig. 19.4b shows the changes in the lift and drag coefficients as the simulation progresses. Results clearly show that in 300 iterations the solution has completely converged with changes in the lift and drag coefficient values becoming negligible.

Fig. 19.4

a Convergence history plots of the residuals of the momentum equations, b variations of the drag and lift coefficients with time

Figure 19.5 shows the static pressure contours around the body. High pressure values are evident on the front of the body due to the recovery of the dynamic pressure contribution. Contours also show a low pressure region immediately downstream the front location of the body as a result of the acceleration of the fluid on a curved surface.

Fig. 19.5

Pressure contours around the body

In Fig. 19.6 the recirculation region is evident on the back side of the body where a low speed region appears.

Fig. 19.6

Velocity contours around the body

The separation region is obvious in the vector plots shown in Fig. 19.7 where a wake is seen to form behind the body. The formation of this vortex region is responsible for pressure losses and is the main contribution to the drag on the body.

Fig. 19.7

Vector plots around body

19.4 Conclusion

The simpleFoamTurbulent solver and boundary conditions developed in previous chapters were used to solve for the turbulent flow around the Ahmed bluff body. Despite the low order convection scheme and the relatively coarse mesh used, the important features of the flow were demonstrated.

References

1.

Ahmed SR, Ramm G, Faltin G (1984) Some salient features of the time averaged ground vehicle wake. SAE Paper 840300

2.

Lienhart H, Stoots C, Becker S (2000) Flow and turbulence structures in the wake of a simplified car model (Ahmed Model). In: DGLR Fach Symposium der AG STAB

3.

OpenFOAM (2015) Version 2.3.x. http://​www.​openfoam.​org

4.

OpenFOAM® User Guide. http://​www.​openfoam.​org/​docs/​user/​snappyHexMesh.​php. London 2012, 2014

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_20

20. Closing Remarks

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

The book covered the foundations of the Finite Volume Method, a method that is currently considered to be one of the most reliable and efficient methods for the simulation of flow and heat transfer problems. It is, thus, not surprising that it is the main numerical technique used in CFD whether in leading commercial codes or in open source libraries and frameworks.

While focused on scalar transport and single incompressible and compressible fluid flow problems, the material presented in this book is quite substantial, ranging from fundamental issues related to the numerics of the FVM to implementation details and CFD applications. All topics were introduced from first principles but were treated thoroughly leading in many cases to covering advanced concepts.

Much of the success of the FVM is attributable to a very active community of developers who have generously shared their techniques and discoveries in journal articles, conference proceedings, and books. Nonetheless it all started with a handful of researchers who were instrumental in setting the foundations for the method. The following is a very short and incomplete list of those early contributors whose publications were, at some time, the basic teaching documents for the method, at least for us the authors. In some way their combined work provided us with much of our early insight into the method, as such we wish to acknowledge their contributions:

B. Spalding, S. Patankar, G. Raithby, B.P. Leonard, F. Harlow, I. Raad, A. Gosman, J.P van Doormaal, S. Muzaferija, I. Demirdzic, M. Peric, G.E. Schneider, P. Galpin, S. Majumdar, C.W. Hirt, C. Hirsch, and V. Voller.

Finally as with many endeavors, there is space for much improvements. Thus it is our hope that you will share with us your ideas and suggestions on how to make the book with the associated codes a better and more useful educational and support tool.

© Springer International Publishing Switzerland 2016

F. Moukalled, L. Mangani and M. DarwishThe Finite Volume Method in Computational Fluid DynamicsFluid Mechanics and Its Applications11310.1007/978-3-319-16874-6_21

Erratum to: The Finite Volume Method in Computational Fluid Dynamics

F. Moukalled1  , L. Mangani2   and M. Darwish3  

(1)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

(2)

Engineering and Architecture, Lucerne University of Applied Science and Arts, Horw, Switzerland

(3)

Department of Mechanical Engineering, American University of Beirut, Beirut, Lebanon

F. Moukalled (Corresponding author)

Email: memouk@aub.edu.lb

L. Mangani

Email: luca.mangani@hslu.ch

M. Darwish

Email: darwish@aub.edu.lb

The online version of the original book can be found under DOI 10.​1007/​978-3-319-16874-6

Errattum to: F. Moukalled et al., The Finite Volume Method in Computational Fluid Dynamics, Fluid Mechanics and Its Applications 113, DOI 10.​1007/​978-3-319-16874-6

Initially the book was published without the extras material. Now it has been included through this erratum. The material is available at http://​extras.​springer.​com/​978-3-319-16873-9

Appendix: uFVM

Introduction

uFVM is a general three dimensional unstructured finite volume-based code developed in Matlab ® for the solution of general single fluid flow and transport phenomena problems. The code is written for academic purpose and emphasizes programming simplicity and readability over performance. The code is capable of dealing with a wide range of flow problems and is easily extensible.

The Base Structure

The code is composed of task specific functions that mimic the numerical functions used in the finite volume method. The user can setup a case by writing a script to read the geometry and define the mathematical model with its associated initial and boundary conditions. An illustrative script file is presented in Listing A.1 showing a test case that involves the solution of a simple scalar equation.

Listing A.1

A script for solving a convection-diffusion problem using uFVM

Reading the Mesh

The uFVM code can read an OpenFOAM ® mesh directly from an OpenFOAM ® case directory. Specifically from the polyMesh subfolder that contains the mesh geometric and topological information. The standard structure of an OpenFOAM ® case folder is presented in Fig.  A.1 .

Fig. A.1

The standard structure of an OpenFOAM ® case folder

The ‘0’ directory is the initialization sub-folder containing the initial and boundary conditions of the fields defined in the problem model. The ‘constant’ directory contains the dynamicMeshDict, which is a dictionary for dynamic meshes, and a ‘polyMesh’ directory special for the description of the problem’s geometry. The ‘system’ directory contains dictionaries that define the case setup. The controlDict is concerned with the general control parameters of the test case, the fvSchemes defines the discretization schemes, while the fvSolution contains information about the solution algorithms and relaxations to be used in the simulation.

uFVM reads and processes the polyMesh folder information in the cfdReadOpenFoamMesh function. The function starts by reading the points file and storing the x, y, z coordinates into a structure array called the nodes array, then the geometric information is read from the faces file in the form of a list of node indices for each face. This information is processed and stored in a structure array called faces. Information about the patches and the associated patch faces is then read from the boundary file and stored in a structure array denoted by boundary. Finally, the owners and neighbors files are read and the elements structure array is composed. Then, the topological information for elements, faces, nodes and their connectivities are processed in function cfdProcessOpenFoamMesh . This is in addition to secondary geometric information such as the volume and centroids of elements, centroids and area of faces, as well as interpolation factors, and other geometrical entities.

At this stage, the mesh contains: the nodes array storing for each node its coordinates, index, and the element/s and faces to which it belongs; the faces array storing for each face its index, the coordinates of its centroid, area, interpolation factor, area vector, the owner and the neighbor, patch index and the nodes that construct it; the elements array storing for each element the index, the indices of the neighbors, the indices of the faces and the nodes constructing the element, volume, face sign and the coordinates of its centroid. Moreover, a boundary structure array is created that contains the boundary types included in the problem and read from the OpenFoam ® boundary file. The array contains an index of the boundary patches and their types, their number of faces and the starting face of each patch. An illustration of the above described structure is displayed in Fig.  A.2 .

Fig. A.2

The internal data structure in uFVM

Setting-Up the Model

Before setting up the equations underlying the physical model and representing the major constituents of any case, the fluid/s involved in the problem should be described. This is done through the function cfdSetupFluid , which is responsible for defining the type of the fluid, its username, molecular weight, type (compressible or incompressible), in addition to some other related information. It should be noted at this stage that all the data that will be used by other functions are saved in a global structure array named Domain. The thermo-physical variables appearing in the governing equations should be defined as well. This is the role of the special function cfdSetupProperty . In this function, the user should insert, among others, the name of the property, its type, and the under relaxation factor needed when updating its value. All data is stored in an element mesh field.

Now the setup of the governing equations can proceed for any problem by using the function cfdSetupEquation . This is where the type of the equation (scalar or vector) is defined along with the initial conditions and the under-relaxation factor. The user can also choose the gradient type to be used for evaluating the derivatives appearing in the conservation equation. A field for each equation is stored on an element mesh size array in the global structure array Domain. For each defined equation, the user can add the various terms ( transient , convection , diffusion , pressure gradient , stress , source , electric potential , Darcy , buoyancy , and drag among others) that constitute the equation. Each term is defined in the code using the function cfdAddTerm . This function relates each term along with the coefficients (density, viscosity, and diffusion coefficient among others) to its equation where the information is stored for later use during assembly. The associated boundary conditions of each equation are then added using the function cfdAddBC , where the type of the boundary condition (inlet, outlet, specified value, specified flux, slip, no slip among others) and its value, if needed, are specified. If any of the equations contains a convective term, then the user has to setup a ‘ mdot ’ (mass flow rate: density multiplied by the dot product of the velocity vector and the area vector) field, which creates a mesh field covering the faces of the domain.

The internal structure of an equation (e.g., ‘Velocity:water’) is shown in Listing A.2 .

Listing A.2

Internals of an equation (model) structure

The structure of a term is shown in Listing A.3 .

Listing A.3

Internals of the term structure

Setup the Computational Fields

This section describes how fields are initialized in the code, each on its prescribed locale (elements, faces, nodes). Adding the function cfdInitializeFields into the script file will automatically initialize the equation field, the property field, and the ‘mdot’ field. An equation is initialized over elements by computing and distributing the initial conditions onto each interior element along with the previously defined boundary conditions. After that, a property is initialized over the associated mesh field, whether it should be computed from a formula or has a constant value, by evaluating or placing the values over elements or faces. The ‘ mdot ’ field is initialized as well by calling the density field (which is a property already defined and initialized) along with the velocity field to compute the value over each face of the mesh. Storing all the initialized fields in the appropriate arrays for later communication is done by each associated function ( cfdInitializeEquation, cfdInitiazeProperty, cfdInitializeMdotField ).

Equation Discretization (Assembly)

After all fields have been initialized and the environment has become suitable to start the solution process, the function cfdAssembleAndCorrectEquation is invoked in order to assemble, solve, and correct the equations governing the modeled problem.

Equation Assembly

For each equation, the internal function cfdAssembleEquation assembles the terms that have already been associated with the specified equation. A coefficient array containing the coefficients of the variable, of size equal to the number of control volumes, is setup using the cfdSetupCoefficients function, as illustrated in Fig.  A.3 .

Fig. A.3

Illustration of the array of coefficients

A process is initiated in cfdAssembleEquationTerms to loop over each term and calculate its fluxes according to the selected or default scheme. The calculated face fluxes and element fluxes are then assembled according to their discretized form into the global coefficient matrix by cfdAssembleIntoGlobalMatrixFaceFluxes and cfdAssembleIntoGlobalMatrixElementFluxes , respectively. After assembling all the terms of a single equation and obtaining the complete array of coefficients, the residuals of the equation are computed using the function cfdComputeResidual according to the prescribed equation of the residuals. After that the under-relaxation factor, already specified for each equation, is applied on the coefficients.

Solving the Equations

Two algebraic solvers are implemented in uFVM, which are the successive over-relaxation method (SOR) and the ILU(0) method. The SOR method is simply the under-relaxed Gauss-Siedel method. With SOR the array containing the coefficients is imported to the solver, which in turn loops over the elements of the domain to solve and update the values of the unknown field ϕ. The system of equations is solved in residual form according to the following equation:

(A.1)

The ILU(0) method follows the methodology described in Chap.  10 , where also the system of equations is solved in residual form.

Whether solving a simple scalar equation or a set of scalar and vector equations (i.e., the Navier-Stokes equations), the solutions of these equations have to be corrected using the cfdCorrectEquation function along with several internal functions specific for the correction of each type of equations: velocity, scalar or pressure (which has a specific treatment). After the correction field is obtained, the phi field at internal nodes is updated. Boundary conditions are corrected, each according to its specified type through the use of any of the following functions: cfdCorrectWallZeroFluxBC, cfdCorrectWallSpecifiedFluxBC, cfdCorrectInletInletBC , and cfdCorrectOutletZeroFluxBC among others. The pressure equation is corrected by executing cfdCorrectPPField and cfdCorrectPressureEquation because of the need to correct the pressure correction and pressure fields. After that, the velocity and the ‘ mdot ’ fields are corrected at the interior element faces as well as at boundaries.

Computing the Residuals

The residual of each equation is calculated using the cfdComputeResidual . First a scaled ϕ for the equation to be solved is calculated as

(A.2)

then the residuals are scaled using

(A.3)

and finally the root-mean square residual is computed over the domain as

(A.4)

The obtained value is stored since it is needed as an indicator for the convergence of the solution and can be plotted as explained later.

Plotting Utilities

Several plotting functions are available in uFVM allowing results in addition to mesh and geometry to be visualized. A summary of these functions is given below.

cfdPlotMesh plots the domain under consideration along with the mesh that covers it.

cfdPlotElements plots any element the user choose or a set of specified elements using the index of each.

cfdPlotFaces plots the faces of the domain using their indices.

cfdPlotPatches plots the full boundary patch that the user choose by using the index of the patch already defined in earlier stages of a case problem.

cfdPlotContours plots contours of the variable over the domain.

cfdPlotField plots any field defined in the solver, as shown in Fig.  A.4 .

Fig. A.4

The ϕ field over the domain of interest

cfdPlotResiduals plots the residual value of each variable per iteration, as shown in Fig.  A.5 .

Fig. A.5

Variation of the residual of ϕ with iterations for a transient run

cfdPlotVelocity is responsible for plotting the mesh and the velocity vectors on the element centroids and on boundary faces, as shown in Fig.  A.6 .

Fig. A.6

A plot of the velocity field over the domain

Interpolation Schemes

Several interpolation functions are included in uFVM serving different purposes. A summary of these interpolation functions is given below.

1.

cfdInterpolateFromElementsToNodes function is used to compute the gradient according to the node-based method and in the cfdPlotField function. A loop over all nodes is performed and for each node an array is created to store the indices of the elements sharing the node. The value of the variable at the node is computed by applying Eq. ( 9.​18 ).

2.

cfdInterpolateFromElementsToFaces function is used in assembling the stress, diffusion, and ‘mdot’ terms as well as in the initialization of fields. Three interpolation schemes (Hyperbolic, Upwind, and Average) are implemented in this function from which the user can choose when computing face values from element values.

3.

cfdInterpolateFromNodesTofaces function is used in computing the gradient according to the node-based method. For a single face, the value at the face centroid is computed from the values at the face nodes using Eq. ( 9.​18 ).

4.

cfdInterpolateGradientsFromElementsToInteriorFaces function is used to interpolate the gradients from elements to interior faces according to the selected interpolation scheme. Four options are available for this function (Average, Upwind, Downwind and Corrected Average). The Average scheme depends on the weighting geometric factor and includes the owner and neighbor of the interior face. The Upwind and Downwind schemes use the value of the upwind and downwind element, respectively, depending on the direction of the ‘mdot’ vector at the specified interior face. The corrected Average scheme resembles the Average scheme but with the introduction of a correction to the interpolated gradient according to Eq. ( 9.​35 ).

Test Cases

uFVM comes with a set of basic test cases that can be used to learn how to setup and run problems using the code. They are also useful as initial templates to setup new problems. The name of files for all test cases start with ‘test’, some of these test cases are listed below.

testAdvection.m

testDiffusion.m

testDiffusion01.m

testDiffusion02.m

testDiffusion03.m

testDiffusion04.m

testFlow01.m

testFlow02.m

testGradients.m

testShearRate.m

testSmithHutton.m

testStepProfile.m

testStepProfile2.m

testTemperature.m

testTransient.m

testTurbulence.m

Any test case can be run simply by calling it from within Matlab ® as a script with no input. More information on uFVM can be obtained throughout the book in the various Computational Pointers sections.

Closing Remarks

uFVM is mainly used as a teaching tool. It is easy to read but it may take some time to get used to, especially the setting up of cases. However it provides a clear implementation of many of the numerics currently used in industrial type CFD codes. The uFVM code was found to provide good and practical insight to students. It is our hope that you will find it as useful in your classroom as we have in ours.