# ComputationalFluidDynamics (CFD)

by

Dr. Sharad N. Pachpute (PhD, IIT Delhi)

## Introduction to Flow Analysis Techniques

In general, science and engineering have been traditionally divided into two parts; experimental and theoretical disciplines.

### Theoretical or Analytical Analysis

• The theory is based  on assumptions, postulations, and laws of actions
• In physics, chemistry, and other science subjects, many theorems are studied  and mathematics helps in quantification and understanding
• These theorems are presented  in terms of independent and dependent parameters
• Analytical analysis helps to provide physical dependency of parameters but it is difficult to solve complex real-world problem example: weather prediction, flows of rivers, testing of large airships, etc.

### Experimental Analysis

• Using theory and mathematical formulation we can solve simple problems in our real life and nature
• Experiment is conducted for simple cases to understand the details of objectives
• Carrying out experiments is expensive, risky and time-consuming
•  There are many limitations  to getting solutions for complex problems either by theory or experiments

### Modeling and Simulation

• Modeling and simulation have emerged as a third pillar in many fields like engineering, molecular dynamics and astronomy
• Modeling and simulation is a techniques to prediction science and explore new knowledge
• It is useful  to  solve real-world problems which can not be solved by theory and may be expensive by experimental analysis
• Computational fluid dynamics (CFD) is  a technique of modeling and simulation based on numerical modeling for fluid flow
• Using the CFD technique, heat and mass transfer, reactive flow, multi-phase flow and combustion can be analyzed using various numerical models
•  Modeling and Simulation is called as the third pillar of science and technology in the 21st century.

## What is Computational Fluid Dynamics (CFD)

### Definition of CFD

• Computational fluid dynamics (CFD) is a technique of flow predictions by numerically solving governing equations of fluid flows. Governing equations are conservation of mass, momentum, heat, and mass transfer. Numerical methods are used to convert partial differential equations into algebraic set of equations. After solving iteratively using computer programs, engineers visualize predicted velocity, pressure and temperature.
• Computational fluid dynamics (CFD) comprises three  steps:
• Pre-processing: Creation of geometry and meshing
• Simulation: Solving governing equations over a meshed model
• Post-processing and results analysis: Predicted physical quantities need to be analyzed qualitatively and quantitatively
• Computational fluid dynamics (CFD) is an interdisciplinary subject. Hence, CFD users have to be familiar with the following subjects as per their specific requirements.

### Essential Subjects for CFD Modeling

1) Mathematics:

• Partial differential equations, integration
• Numerical Methods:  finite volume method (FVM), finite element method (FEM), finite difference method (FDM)

2) Flow Physics:

• Fluid mechanics: Properties of fluid, Laminar, and Turbulent Flow
• Heat and mass transfer: Conduction, Convection, and radiation heat transfer
• Reaction in the flows: Passive flow in pipe or duct. reactive flow  in the combustion
• Phases of material: One or more phases can interact each during flow
• single-phase: Example –  air flow through pipe
•  Multi-phase flow like boiling or condensation
• Other flow physics: Magnetic or electric field acting on the fluid
• Fixed or moving boundaries: Moving or stationary walls in turbo-machinery
• Multi scale and multi-domain: there can be multiple scales in the system like  battery

3) Computer science:

Programming tools like C or C++ need to be learned by CFD users initially. Familiarity with CFD software is essential for geometry, meshing,  simulation and post-processing. Parallel computing may need for complex industrial problems,  large eddy simulations (LES ), and DNS. Most CFD solvers are developed in C or C++ which are easy to run multiple processors (HPC). Python or scripting languages are used to control the simulations on hardware.

• Hardware: Laptop, PC, HPC, Supercomputer
• Programming tools: C, C++, Python etc
• CFD software: ANSYS FLUENT, CFX, Open FOAM, Star CCM, COMSOL Multi physics

4) Experimental data for validation:

• Validation of CFD results is essential for credibility of numerical models
•  Results of CFD simulations need to be reliable and consistent with experimental results

## Scope of CFD Modeling

### Comparison of Simulation  and Experimental Analysis

• As discussed above, simulation and experiment are two commonly used methods for design and analysis
• Simulations provide a thorough analysis at a lower cost compared to experimental analysis
• Hence CFD is used in a wide range of industrial applications where fluid flow is involved like automotive, aerospace, power generation, etc
• CFD is used for design and optimization of industrial problems

• CFD has a large potential to solve industrial problems at bigger scale due to continuous improvement in computational power  and numerical models

• The cost of analysis is low compared to experiments
• Provide detailed information
• It can applied to a variety of problems
• CFD analysis requires less time to get results compared to experimental for most of complex cases. Hence, wind tunnels are replaced with CFD simulations in many universities and industries as shown below
• CFD analysis is an effective method for design optimization in many automobile, aerospace, and chemical industries
• To carry out a wind tunnel test is expensive and it requires a lot of time for experimental setup
• For measurement in experiments, we can not fix the probes or sensors to measure velocity and pressure at all locations.

## Applications of CFD Modeling

• Simulations provide insight into physical parameters (e.g. velocity, temperature, pressure, pollution level,.etc.) that are difficult to study using traditional (experimental) techniques.

i) To find the impact of Smoke and pollution level:  Flow pattern for an oil fire

ii) Turbo machinery Analysis
• Flow pattern for Turbo-machinery is shown below
• The first step of CFD is to Identify the flow physics involved in the pump:turbo-machinery, turbulent flow, multi-phase flow  (water and air)

iii) To predict the temperature distribution in boiler

• CFD analysis of boiler is shown below:Temperature  for Turbulent Combustion of a coal fired boiler
• First step of CFD is to Identify the flow physics involved in boiler: turbulent flow, heat transfer (conduction, convection and radiation), multi-phase flow (particle and flue gas), reactive flow (combustion)

.

## Classification of Fluid Flow

•  Fluid flow is classified based on the type of physics involved in a particular flow. CFD user has to select correct CFD Models as per flow physics
• For each flow physics, different numerical models have been developed based on assumptions and mathematics. All models are to be consistent with experiments
• A variety of numerical models are available in most of commercial CFD solvers. Read the following articles for complex flow modeling.

### Laminar and Turbulent flow

• In general, the Reynolds number is used to determine the flow whether it is laminar or turbulent

• Re < Recr:  Laminar flow
• Re > Recr : Turbulent Flow flow
• The transition from laminar to turbulent flow depends on the surface geometry, surface roughness, free-stream velocity, surface temperature, and type of fluid, among other things.
•  If the flow becomes turbulent for the small sectional area, then the CFD user has to select an appropriate turbulence model  while modeling the flows
• To simulate complex turbulent flow, turbulence models are used for numerical simulation
• CFD solver can not decide the flow either laminar or turbulent. It solely depends on CFD users to decide the flow type and relevant numerical models.

### The regime for Laminar and turbulent Internal Flow

• Example 1: Buoyant flow from a cigarette  shows that laminar and turbulent regions are formed in fluid flow Regions of fluid flows: Laminar Transition, and Turbulent flow

• Example 2:  Water falling from a tap  Water falling from a tap
• Example 3:  Water channel flows show that laminar flows in the channel and turbulent around the gate due to increase in velocity

### Forced Flow vs Natural (free) Flow

• Forced flow: the flow is driven by external means like a fan, pump, blower, etc.
• Natural (free) flow: the Flow is driven by the density difference between hot and cold fluids

### Fluid Flow with  Fixed vs Moving Boundary

• Fixed/stationary boundary: boundaries/ walls are fixed
• Example (1) of a fixed wall boundary: for flow through a circular pipe, the pipe wall is fixed and stationary (no-slip)
• Example (2) of a fixed wall boundary: for flow through a control valve, the pipe wall is fixed and stationary (no-slip)
• Example of a moving wall boundary: Moving/dynamic boundary: the boundaries/ wall move relative to the fluid: (a) Air flow over a moving car, (b) Air flow over a wind mill
• In flow over a windmill, air flows over blades which rotate about its axis. The lift force created due to pressure difference causes torque for rotation of blades.
•  For flow through the pump, the impeller rotates and pushes the fluid through the outlet pipe. Due to a change in boundaries, the flow physics and CFD models are also changed compared to simple pipe flow problems

### Single vs Multi-phase flow

• Single Phase flow : only one phase exits in the fluid system Examples: water through a pipe, air flow over a surface etc.
• Multi-phase flow: more than two or more phases interact with each other.
• Examples of multi-phase flows are boiling flow, condensation, bubble column, etc.
• Water evaporation and boiling consist of two phases water and steam
• Condensation consists of two phases water and steam
• To model the flow when two  (interpenetrating or separated)phases, multiphase models are used based on approximation and cost of simulations

### Passive Flow vs Reactive Flow

• Non-reactive flows: no chemical reaction takes place between the species
• Reactive flows: chemical reaction takes place between the species. Combustion is considered a flow with fast reactions. Air, fuel, and ignition source are major elements of combustion.
• In the combustion chamber, the reaction takes place between fuel species and oxygen in air. Products of combustion are released during the reactions.

• Heat is released during combustion. The liquid phase changes to the gas phase by absorbing heat from the combustion. The evaporated fuel species react with oxygen in the surrounding air.
• Solid combustion comprises the pyrolysis stage and devolatilization, a reaction with oxygen
• For details of reactive flow modeling, read the basics of combustion in this website. The majority of flow in combustion is turbulent for good mixing of fuel and air. It can lead to stable flames. Turbulent combustion modeling needs to be studied in detail before CFD modeling.

## Transport Equation for CFD Modeling

### Physical transport phenomenon

• In fluid flow, the transport of various physical quantities such as mass, momentum, energy, and species is involved.
• CFD user must know the governing equations and the physical meaning of various terms in equations.

### A caricature of physical transport phenomenon:

• Transport of water is used  from the source point to  the location of fire extinguishing

• CFD users must know the governing equations and the physical meaning of various terms in equations.

1) Conduction (diffusion): need a medium for the transfer of mass, momentum, heat, and species at the molecular level.

2) Advection: need a medium for transfer of mass, momentum, heat, and species at the bulk level.

3) Radiation: no need for a medium for heat (Not applicable for mass, momentum, and species)

• In general, the conservation equation for any physical conserved variable is written as:

Unsteady term + Advection term = Diffusion term + Source /sink terms

### The general form of governing equation

• The general form of a governing equation in the context of physics and engineering often takes the form of a differential equation.
• The specific form of the equation depends on the physical system and the laws that govern its behavior

## Numerical Solution Procedure

### Overview of CFD or Numerical Modeling

•  Computational fluid dynamics (CFD) is the science of predicting fluid flow, heat and mass transfer, chemical reactions, and related phenomena by solving numerically the set of governing mathematical equations• Governing (PDE) equations are Conservation of fluid flow, heat and mass transfer, and species, etc.
• Generally, CFD works based on the Finite volume methods (Conservative Method).

• The fluid region of pipe flow is discretized into a finite set of control volumes (mesh/cells).
• Partial differential equations (PDEs) are discretized into a system of algebraic equations using finite volume method or finite element method

### Steps for CFD Modelings

• Pre-processing comprises making geometry and meshing
• Solver selection of physical models,  governing equations, solution procedures
• Post-processing of CFD results
• The steps for CFD modelings are given as below:
1. Define the objectives of modeling
2. Create the geometry  or computational domain using the CAD tools like Space claim, solid works
3. Create the meshing using meshing software like ANSYS Meshing, Hyper mesh
4. Set up the solver and physical models
5.  Compute and monitor the solution
6. Examine and save the results in plots, contours, and flux reports
7.  Consider revisions to the numerical or physical model parameters, if necessary

## CFD Software for Commerical and OpenSource

• The most commonly used CFD software and tools for numerical simulations  are shown below

### Comprehensive CFD Software

• In the last four decades, CFD solvers have been developed for a wide variety of complex flows like turbulent, multiphase and combustion etc.
• These solvers have been used in many industries and  well-practiced numerical models are available there
• Many industries have compared their plant (practical) data with CFD results
• Example: ANSYS FLUENT, STAR CCM, and OpenFOAM

### Semi-comprehensive CFD Softwares

• Some CFD solvers are developed for certain applications but not  practiced on large scales of industrial problems
• These solvers need to expand their scope of applications for large-scale industries
• Example: COMSOL Multiphysics, CONVERGE

## Discretization of Computational Domain (Meshing)

### Elements of Meshing

Computational is divided into to finite number of volumes or elements in meshing. Meshing consists of the following important identities.

• Cell: control volume into which domain is broken up
• Node: grid point
• Cell center:  center of a cell
• Edge: boundary of a face
• Face: boundary of a cell
• Face defines the cell zones (solid or fluid region) for two dimensional (2D) computational domain. Hence, CFD users has to define the fluid zone for the face
• For, the 3D domain, the face can be a boundary like an inlet, outlet or wall etc.
• All essential faces should be named in meshing before exporting to the CFD solver
• Zone:
• It is a grouping of nodes’ faces and cells
• For, 3D domain, the volume region defines fluid or solid regions
• All essential cell zones should be named  either solid or fluid in meshing before exporting to CFD solver
• Domain: It is a group of node, face and cell zones Element of mesh in CFD model

### Structured vs non-structured meshing

• The process of mesh generation is generally classified into two categories based on the topology of the elements that fill the domain
•  After the selection of the CFD domain, the next step is to divide the domain into a finite number of volumes or cells based on the physics to be resolved.
• Types of Meshes for Computational Domain.

### Assessment of Mesh Quality in CFD

• Mesh quality is essential for correct CFD simulations. Three ways are to  measure of the quality of mesh
• Skewness /Orthogonal quality:
• The skewness of the mesh should be below as much as possible
• Higher skewness can slow down the convergence of simulation and incorrect computations fluxes near walls.
• Skewness and orthogonal both are opposite each other. Higher orthogonal quality means lower the skewness of mesh

### Meshing Thumb rules

• High-quality mesh and correct numerical schemes mean good convergence of residuals
• For ANSYS FLUENT: Orthogonal quality =  1 – cell skewness
• For complete Hexahedral elements, skewness is zero. It is a non-zero value for inclined faces
• Try to keep skewness below 0.98 so that the CFD simulation will not diverge due to unbounded solutions
• Mesh quality can be improved by converting the tetrahedral cells to polyhedral cells in CFD solvers (ANSYS FLUENT, Star CCM)
• For poor-quality mesh, the solutions can be obtained by controlling the relaxation factor or selecting near-wall gradient schemes
• Try to keep at least three-element in narrow gaps which is a shadow or wake region.
• Add more elements (at least 10 cells) in high-velocity fluid zones to better numerical convergence
• Smoothness (change in size):
• Sudden jumping in the mesh should be avoided in the high gradient region (like inlet and near-wall)
• A growth factor of  1.2 is recommended between adjacent cells
• Smoothness in the mesh is very essential near wall boundaries.
• Aspect ratio:
• Select it as per the need for simulation
• In the direction of the high gradient region, the aspect ratio should be less ( < 20) for laminar and turbulent flow (RANS Modeling).
• A very low aspect ratio of 2-3 is needed for multiphase-separated flows and large eddy simulations (LES)
• In the direction of no gradient region, a higher aspect ratio ( ~ 250)  is enough to reduce the mesh size. ## How to Check Mesh Quality for CFD Simulations

• Checking mesh quality is an essential step in Computational Fluid Dynamics (CFD) simulations, as it directly affects the accuracy and reliability of the results.
• Remember that mesh quality checks should be performed before starting the simulation, and if you find issues, it’s best to correct them and re-generate the mesh as necessary. A good-quality mesh is a fundamental prerequisite for obtaining reliable and accurate CFD results
• Poor mesh quality can lead to inaccurate solutions, convergence issues, and increased computational costs. There are several metrics and tools available to assess mesh quality.
• Here’s a general guide on how to check mesh quality in CFD simulations:

Mesh Visualization

• Start by visually inspecting the mesh to get a rough idea of its quality.
• Use your CFD software’s mesh visualization tools to display the mesh in 2D and 3D.
• Look for irregularities, poorly shaped elements, skewed faces, abrupt changes in element size, etc.

Mesh Statistics:

• Most CFD software provides mesh statistics that give you quantitative information about the mesh quality.
• Look for metrics such as minimum and maximum element volumes, aspect ratios, skewness, orthogonality, etc.

Aspect Ratio

• The aspect ratio is the ratio of the longest edge to the shortest edge of an element.
• High aspect ratios can cause accuracy issues, especially in boundary layers.
• A well-shaped element should have an aspect ratio close to 1.

### Skewness

• Skewness measures the deformation of an element from its ideal shape (usually an equilateral triangle or cube).
• High skewness can adversely affect solution accuracy and convergence. Aim for low skewness values.
• Some CFD meshing tools create polyhedral cells to reduce skewness and overall mesh count.

Orthogonality

• Orthogonality measures the angle between the face normal and the cell face.
• Low orthogonality can lead to interpolation errors and reduced solution accuracy, particularly in finite-volume methods. Higher orthogonality is desired.

Mesh Resolution:

• Ensure that the mesh is adequately refined in areas where significant flow gradients or complex flow features are expected.
• Use mesh refinement techniques such as adaptive meshing or multi-zone meshing to improve resolution where necessary.

### Y+ Value for Turbulent flow

• For turbulence modeling using the wall functions approach, it’s crucial to check the y+ value.
• The y+ value represents the distance of the first cell center from the wall in wall units.
• Maintaining y+ in an appropriate range (typically < 5 for boundary layer flows)  ensures accurate wall modeling.  It is between 30 and 200 for high-speed flows.

### Mesh Sensitive Study:

• Perform a mesh convergence study to determine the sensitivity of your results to mesh refinement.
• This involves running simulations with progressively finer meshes and comparing the results. Convergence is achieved when further mesh refinement does not significantly change the results.

Boundary Layer Resolution

• Ensure that the boundary layer is adequately resolved with a sufficient number of cells in the region near the walls.
• This is crucial for capturing accurate boundary layer behavior.

Mesh Quality Improvement Tools

• Based on the identified mesh quality issues, you may need to clean up or re-mesh certain regions of your domain to improve mesh quality.
• Many CFD software packages like ANSYS FLUENT offer mesh improvement tools to help with this process by removing highly skewed cell
• Maximum skewness should be 0.97. You can simulate but you need to reduce the under-relaxation factors for pressure, momentum, and turbulent quantities.

## Discretization Methods for CFD

• The governing equations like mass, momentum and energy are expressed in terms of partial differential equations (PDEs).
• These equations are space and time-dependent.
• We can not solve PDEs like ordinary differential equations. However, partial differential equations are boundary value problems.  After discrediting with a numerical method, we can compute values based on initial and boundary conditions.
• Discretization converts the transport equation (mass, momentum, and energy) in the partial differential form to a set of algebraic equations. Three numerical methods are widely used to discretize the partial differential equations namely:
• Finite Difference Method (FDM)
• Finite Element Method (FEM)
• Finite Volume Method (FVM)
• The discretization methods approximate the PDEs of fluid flows with numerical model equations, which are solved using different numerical methods.

### Finite difference method (FDM)

• The computational domain is usually divided into hexahedral elements (grids) and the numerical solution is obtained at each node
• The finite difference method (FDM) is simple to understand when the physical elements are defined in the Cartesian coordinate system, but with the use of curvilinear transforms the method can be extended to domains that can not be easily represented using  brick-shaped elements
• The discretization results in a system of equations of the variable for grid points, and once a solution is obtained then a  discrete representation of the solution is obtained.
• Note the following points for FDM:
• It is applicable only for regular grids (equal size of meshing).
• This method is based on Taylor’s series of differentiation. Finite difference methods for spatial derivatives with different order of accuracies is obtained using Taylor expansions like first or second-order upwind difference scheme (UDS), central differences schemes (CDS), etc.
• The FDM  is difficult to use for non-uniform grids. Hence it is rarely used for CFD solvers
• This method is not easy to implement conservation of mass, momentum, and energy
• Taylor series of expansion discretized differential terms in partial differential equations
• Forward, backward, and central schemes are commonly used finite difference schemes to discretize partial differential equations
• Discretization is carried out over all the nodes of the computational domain

Finite Volume  Methods (FVM)

• This approach is suitable for both irregular or irregular meshes. is based upon an integral form of the PDE to be solved (e.g. conservation of mass, momentum, or energy).
•  The governing equations are solved for a given finite volume (or cell) using finite volume methods
• The computational domain is discretized into finite volumes and then for every volume, the governing equations are solved.
• The final forms equations after discretization involve fluxes of the conserved variable (mass, momentum, and energy), and thus the calculation of fluxes is essential in this method

Note:

• The Finite volume method is conservative (for mass, momentum and energy, etc). Hence, the FVM Discretization is widely used for many CFD solvers (e.g. ANSYS FLUENT, Open FOAM)
•  For Refere ANSYS FLUENT User Guide: FLUENT_NUMERICAL_ METHODS

### Finite  Element Methods (FEM)

• This numerical method is based upon a piecewise representation of the solution in terms of specified basis functions.
• The computational domain is divided up into smaller domains (finite elements) and the solution in each element is constructed from the basis functions.
•  This can be a double-edged situation, as the section of basis functions is essential and boundary conditions can be more difficult to formulate for complex geometries. A set of equations is obtained (for nodal values) are solved to get a solution.
• To get numerical solutions, a  set of  equations are obtained using the conservation equation: Field variables are written as the basis functions, the equation is multiplied with appropriate test functions, and then integrated over an element. Since the FEM solution is defined in terms of specific  functions, a significant solution is obtained by solving the equations algebraically.
• The finite element method (FEM) is used to compute such approximations.Take, for example, a function u that may be the dependent variable in a PDE (i.e., temperature, electric potential, pressure, etc.) The function u can be approximated by a function uh using linear combinations of basis functions according to the following expressions:
• The FEM discretization is used by some CFD solvers (e.g. COMSOL). For the COMSOL CFD solver, click here: COMSOL_NUMERICAL_METHOD
• Finite Difference Method (FDM) is a numerical technique for solving partial differential equations (PDEs) that arise in various fields of science and engineering.
• COMSOL Multiphysics is a commercial software platform used for modeling and simulating physical systems, which includes tools for solving PDEs through various numerical methods, including the Finite Element Method (FEM), Finite Volume Method (FVM), and Finite Difference Method (FDM)

### Which method (FDM/FEM/FVM) is the best suited for CFD Modeling?

• The comparison of the three methods is not straightforward due to differences in numerical procedures
• Finite volume method (FVM) and finite difference method (FDM) provide discrete solutions, but the finite element method (FEM) provides a continuous (up to a point) solution.
• FVM and FDM are generally considered to be easier for programming compared to FEM. This point may be vary user to user
• Most research scholars adopt the FVM method for numerical modeling of fluid flows.
• The FVM  easily provides better conservation properties for mass, momentum, and energy, If you are interested in deciding which method is more suitable, then go through the literature on three methods

### Interpolation Scheme in CFD Solver

• The domain of interest is divided into finite number of cells or volumes
• Based on on the spatial information of nodal point, area faces and volume cells, governing equations (mass, momentum and energy) are dicretized for both space and time
• Different numerical techniques are used for each term in governing equations like unsteady term,  convection term, diffusion, viscous and  body forces

1) Upwind Differentiating Scheme (UDS)
• Flow direction-dependent Øe
• This approximation is of first-order (O(Δx))
•   Numerically diffusive
2) Central Difference Scheme (CDS):
Linear interpolation between the two nearest nodes

This interpolation is of second order, O(Δx2)

To construct a parabola for interpolation three points are necessary
This quadratic interpolation is of third order, O(Δx3).

• Temporal derivatives can be integrated either by the explicit method  or implicit method
• Explipit Method: Euler, Runge-Kutta
• Implicit method : Beam-Warming method

Methods for time integration:
1) Explicit or forward Euler method: accuracy in order O(Δt),

2) Implicit or backward Euler method:: accuracy in order O(Δt)

3) Leapfrog method (midpoint rule): explicit method, accuracy in order O(¢t2)
4)Crank-Nicolson method (trapezoidal rule):
A summary of standard time stepping schemes is given below:

#### Explicit Method

direct computation without solving a system of equations
easy to programme  and parallel computing
few number of operations per time step
Disadvantage: strong conditions on the time step for stability

#### Implicit Method

Advantage: much larger time steps possible, always stable
• every time step require the solution of a system of equations
• more number of operations
• difficult to programme  and parallel computing

### Solution of Linear Equations Systems

summing all the approximated integrals we produce an algebraic equation at each control volume
where the matrix A is always sparse.

### 1) Direct methods

• Gauss elimination
• LU decomposition
• Trid-iagonal matrix algorithm (TDMA)

### 2) Indirect or iterative methods:

• Jacobi method
• Gauss-Seidel method
• Successive over-relaxation (SOR)
• Multi-grid methods

## Grid-based Coupling of Pressure and Velocity

### Colocated grid

• Node for pressure and velocity components at the control volume (CV) center.
• Same CV for all variables.
• Possible oscillations of pressure

### Staggered grid

• The different unknown variables are located at different grid nodes.
• Pressure is located in the cell centers, velocities at cell faces.
• Strong coupling between the velocities and pressure helps to avoid  oscillations
• Another staggering method is the Arbitrary Lagrangian-Eulerian (ALE).

## Pressure Velocity Coupling – Algorithm

After the discretised form of the governing equation (Navier-Stokes system), we get a set of equations with  linear dependence of  pressure and velocity, or  vice-versa. This inter-equation coupling is called a pressure -velocity coupling. A special numerical treatment is necessary in order to the pressure-velocity  coupling. This is achieved by following algorithm such as SIMPLE, SIMPLEC, PISO, Coupled solver.

### SIMPLE Algorithm

• Semi-implicit method for Pressure-linked Equations
1. 1.Advance to the next iteration t(n)=t(n+1)
2. Initialize u(n+1) and p(n+1) using latest available values of u and p
3. Construct the momentum equations
4. Under-relax the momentum matrix
5. Solve the momentum equations to obtain a prediction for u (n+1)
6. Construct the Pressure equation
7. Solve the pressure equation for p(n+1)
8. Under-relax p(n+1)
9. Correct the velocity for u(n+1)
10. If not converged, go back to step 2
11. Correct the fluxes for ϕ(n+1)

b) SIMPLEC: Semi-Implicit Method for Pressure Linked Equations-Consistent

• The pressure-correction under-relaxation factor is generally set to 1.0, which helps for faster  convergence
• This method is suitable for turbulent flow with pressure-varying fields

C) PISO: PressureImplicit with Splitting of Operators (PISO)

• PISO consists of one predictor step and two corrector steps
• This method helps to check the  mass conservation in each iteration using predictor-corrector steps

d) Fractional step method

• This method solves  the incompressible Navier-Stokes equations with  primitive variables by  block LU decomposition.
• This method helps to solve issues of  boundary conditions for the intermediate flow variables and the pressure

### Pressure Velocity Coupling in OpenFOAM

For details of OpenFOAM schemes and algorithms refer the post.

• simpleFoam:  based on SIMPLE algorithm
• pisoFoam: based on PISO formulation
• a combination of SIMPLE and PISO

## Properties of Fluid

• A  CFD user must be familiar with what fluid/solid properties are given to the CFD solver (e.g. FLUENT, OpenFOAM and COMSOL etc.) as input data and what properties will be calculated by the CFD solver

## Boundary Conditions

The following boundary conditions are commonly used in a variety of  CFD domains:

#### 1) Inflow (inlet)condition:

• Convective flux is prescribed like velocity or mass flow rate inlet
• Input to be specified at he inlet: Momentum (velocity, mass flow rate, pressure, turbulent conditions),
• Thermal (temperature, emissivity and shell conduction), Species ( mole/mass fraction), Multi-phase (volume fraction of phase, particle size or distribution.

#### 2) Wall:

• No fluid penetrates the boundary, i.e. convective flux is zero.
• Two types of wall conditions: no-slip (fluid is at rest at the wall) or free-slip (no frictional losses at the boundary).
• Wall can be slip or no-slip type
• A wall can be stationary or moving wall (like a rotor for turbo-machinery)
• Input to be specified at the wall: Momentum (velocity, roughness), Thermal (temperature, convective HTC, emissivity and shell conduction), Species, Multi-phase

#### 3) Outflow (outlet) condition:

• Convective flux independent of the coordinate
• Normal to the boundary. zero gradient BC for all variables except pressure
• It is more suitable for a longer  pipe flow with fully developed profiles of velocity or temperature
• It is also called zero-gradient BC  for (U,T,Y except P) in  OpenFOAM

#### 4) Symmetry condition:

• This boundary is used when flow does not cross the boundary
• Across the boundary all gradient are zero

#### 5) Periodic (cyclic) condition:

• Repetitive boundary conditions
• It can be transnational or angular
• Boundary conditions used for pipe flow or free stream flow over a circular cylinder
• Boundary conditions for flow through a pipe or duct is shown below. The inlet is specified with a fixed velocity
• Initial Boundary conditions for flow over a cylinder are defined as below
• Most of boundary conditions are defined based on fixed value and fixed gradients of velocity, pressure and temperature. That understanding will help decoding open FOAM CFD solver: Adiabatic wall ( dT/dx =0) and  Outlet (dT/dx=0)

## Example of CFD Modeling: Laminar Flow Through the Circular Pipe

Performing a Computational Fluid Dynamics (CFD) analysis of laminar flow through a circular pipe involves using specialized software like ANSYS Fluent, COMSOL, OpenFOAM, or other CFD tools to model and simulate the fluid flow in the pipe.

Here’s a step-by-step guide on how to set up and conduct a CFD analysis for laminar flow in a circular pipe:

## Geometry and Meshing

• Create a 3D model of a circular pipe with appropriate dimensions.
• Generate a mesh that discretizes the pipe geometry. For laminar flow, a structured mesh is often used, but unstructured meshes can also be employed. Ensure a finer mesh near the pipe walls to capture boundary layer effects

• Meshing of Geometry:
•  Determine the mesh parameters, such as element size, growth rate, and the number of divisions for different regions of the pipe.
• Choose the meshing method appropriate for your simulation. There are two primary methods: structured and unstructured meshing.
• Structured Meshing is used in simulation
• This method is suitable for simple geometries and is often used for laminar flows
• It involves creating a grid-like structure with uniform or structured element sizes within the pipe.
• Meshing a pipe in a Computational Fluid Dynamics (CFD) simulation is a crucial step to accurately capture the flow characteristics. The goal is to create a mesh that adequately represents the geometry and fluid domain while being efficient in terms of computation. Here are the steps to mesh a pipe:

## CFD Solver Set Up

Define the Physics:

• Specify the type of fluid you are simulating and its properties (density, viscosity).
• Set up the laminar flow physics.
• In most CFD software, you can specify laminar flow using the appropriate turbulence model.
• For laminar flow, this typically means using the “laminar” option.
• Specify the governing equations for the flow. In the case of laminar flow, you are solving the steady-state incompressible Navier-Stokes equations. These equations describe the conservation of mass and momentum in the fluid.

Boundary Conditions

• Define the boundary conditions for the problem, including the inlet and outlet conditions.
• For laminar flow, you usually specify a known velocity at the inlet and either a fixed pressure or outflow condition at the outlet.
• Physical Model: Viscous Laminar
• Boundary Conditions
• Inlet: fixed mass flow rate or velocity
• Outlet: outflow (zero gradient for velocity)

Solver Settings:

• Choose a solver appropriate for your problem. Laminar flow problems are typically well-behaved and can often be solved using pressure-based solvers. Configure the solver settings, such as convergence criteria, time step (if transient), and numerical schemes.
• Pressure Velocity Coupling: SIMPLE
• Numerical Discretization Schemes
• Pressure: Standard
• Momentum: QUICK
• Convergence criterion: 10^-06

Initialization:

• Provide an initial guess for the flow field. For laminar flows, a uniform velocity field is often a good starting point.

Run the Simulation:

• Start the simulation and let the CFD software iterate to reach a converged solution.
• Monitor the convergence and adjust settings as necessary.

Post-Processing:

• Once the simulation is complete, you can visualize and analyze the results.
• Common post-processing tasks include velocity and pressure profiles, shear stress distribution, and streamlines within the pipe.

## CFD Results and Analysis

• Compare your simulation results with experimental data or analytical solutions if available to validate your CFD model.
• It’s important to note that the accuracy of the results depends on the quality of the mesh, appropriate boundary conditions, and accurate modeling of the fluid properties.
• Additionally, always ensure that the software you are using is properly validated and that you have a good understanding of the underlying physics to set up the simulation correctly
• Qualitative results: Contours and velocity vectors

### Validation of CFD Results

• Comparison of CFD results with theory/ experiment
• To get the credibility of  CFD models, results obtained for numerical simulations need to be validated against theoretical or experimental data
•  In the following figure, the pressure drop and fully developed velocity profiles  are the same with those of CFD simulations and theoretical data laminar flow through pipe

### Conclusion

• Computational Fluid Dynamics (CFD) is a flow prediction technique
• It is useful for design and optimization of problems in fluid mechanics, heat transfer, multiphase flows
• Due to the low cost of flow analysis, CFD modeling is popular in many industries

## References

### 9 thoughts on “Basics of CFD Modeling for Beginners”

1. Excellent

2. 3. This is nice.please could i get resource materials for 3D meshes and solvers?

• Thank for your feedback, You can email to: info@cfdflowengineering.com to get learning materials

4. Very well written with nice figures for CFD beginners.

5. It’s really nice and very good presentation for better understanding. Hats off for your great work.

6. CFD is the acronym for computational fluid dynamics and, as the name suggests, is the branch of fluid mechanics that makes use of computers to analyze the behavior of fluids and physical systems. CFD modeling and analysis became a popular online simulation solution as the difficulty grew in applying the laws of physics directly to real-life scenarios in order to make analytical predictions. This fact became especially prevalent for fluid flow and heat transfer engineering problems.

7. Respected sir,

I have used the CFD modelling study materials in ” https://cfdflowengineering.com/basics-of-cfd-modeling-for-beginners/” published by you. They were of great help in my preparation for the final year UG project. Thank you for the great resource. Also, I have seen a comment by you on the page with your mail ID to get in touch with you for more study resources on the same. It would be very kind of you if you could share the resources with me.
Thanking you in anticipation.

Priyanka Rajeev
UG Student
Dept. of Mechanical Engineering
National Institute of Technology Puducherry

8. 