All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
CONTENT: Abstract. Problem Statement. A Brief Introduction to OpenFOAM. Theory and Governing Equations. Geometry and Mesh Generation. Physical Model Set-up. Numerical Solution. Post-Processing. Mesh Refinement. Results and Conclusion. …
Shivam Gupta
updated on 17 Jul 2020
CONTENT:
Abstract
Backward Facing Step (BFS) problem is one of the intriguing problems in the field of Computational Fluid Dynamics. This project presents the 2-D numerical simulations of laminar backward-facing step flow using the OpenFOAM v6.0 package. The objective of this problem is to produce mesh by using the OpenFoam software and to show the changes in velocity and pressure gradients by using ParaView, open-source post-processing software for given mesh grading factor. At first, the whole analysis is performed using the simple-graded mesh, and then refined mesh is used to observe the effects it made on final plots as the results. This report includes the transient analysis of our computational flow using icoFoam solver. As a result, the velocity contour over the whole domain, and variation of velocity near the step are plotted after achieving the steady-state.
PROBLEM STATEMENT
Consider a 2D laminar, incompressible and Newtonian fluid flow over the Backword-facing step with given kinematic viscosity as 10−5m2/s. The geometry of the Backword-facing step is shown in the above figure (all the values shown in figures are in m). Consider the 'No-slip boundary condition ' on every wall under the domain. Now, perform the transient 2D CFD simulation of the backward-facing step using OpenFOAM v6.0 package by first creating a non-grading mesh and then graded mesh, to observe the effect of grading factor on our final results. There are a total of four simulations you need to perform in which grading factor is changed from 1 to 0.2, 0.5, and 0.8 at the walls to observe the effect of grading.
For the results, you need to create the velocity contour and plots of velocity near the step-domain, for each grading factor, to observe their effects. Assume constant velocity inlet and constant zero gauge pressure outlet as the initial boundary conditions. The flow velocity depends on the Reynold number, so in our case for the laminar region, consider the value of inlet flows Reynolds number as 1500. Run the simulation for 0.5s and take the different value of time step for different mesh such that it satisfies our Courant–Friedrichs–Lewy condition. The problem statement should be carried out with the aid of tutorial named cavity under the icoFoam solver with appropriate Geometry, Mesh, Boundary and initial conditions are created by modifying the script files from the respective solver.
Mesh Specification
A BRIEF INTRODUCTION TO OpenFOAM
The program used to solve the different flow problems in this report is OpenFOAM. OpenFOAM is a free open source CFD package and can be downloaded from their website. It is developed by OpenCFD Ltd and distributed by the OpenFOAM Foundation. It is widely applicable because of the many different solvers implemented in the software. The software package can be used in both commercial and academic organizations to solve all types of problems (from complex flows with chemical reactions to turbulence and from electromagnetics to financial issues). The broad applicability of this package is caused by the ability of the software to solve partial differential equations very efficiently. The package is developed continuously not only by the people behind the code but also by users from all over the world.
The package includes software from the preprocessing up to the post-processing processes. The package contains over 80 solver applications for different types of problems and over 170 utility applications that perform the pre- and post-processing tasks. One of the significant advantages of OpenFOAM is the ability to run processes in parallel, which dramatically improves the speed of the calculations and processing of large amounts of data. Because there are so many different solvers and techniques implemented, it is straightforward to switch to improve the quality of the results or to get a stable run, for example.
THEORY and GOVERNING EQUATIONS
Backward-facing Step
Flow separation is a common and interesting phenomenon in fluid mechanics with significant effects in practical application. Thus, it has been the focus of intensive study for many years. A standard set of simple geometric configurations including the flow in a pipe with a sudden expansion, the flow in a pipe with an obstruction such as an orifice, the flow over an obstacle in a channel and the flow in a channel with a sudden expansion, has been proposed as representative test cases. Among these, the backward-facing step flow has become a very popular benchmarking and validation test for computational fluid dynamics (CFD) simulations owing to its simple geometry and the availability of a good number of quality experimental data.
Backward Facing Step (BFS) problem is one of the vital flow geometry for investigating separated flows. In this problem, the flow enters from the inlet passes through a constant area duct and exits into another duct having a cross-sectional area larger than the inlet duct. As this occurs, a recirculation zone occurs at the 'step’ of the duct having a larger cross-sectional area. Even though it is a simple and common problem but it has a wide scope, which makes it a building block for a variety of applications. This recirculation depends on the Reynolds number of the flow, size of the step, expansion ratio, aspect ratio (in 3D case), etc. This project dives into one such problem of 2D BFS computationally using OpenFOAM® in which the results are obtained for the different graded mesh.
Backward facing step flow is of particular interest because it facilitates the study of the reattachment process by minimizing the effect of the separation process. In contrast, for other separating and reattaching flow geometries, there may be a stronger interaction between the two. The principal flow features of the backward-facing step flow are illustrated in the above figure.
Governing Equations
The backward-facing step flow problem is governed by the mass conservation equation and the Navier-Stokes equations of motion. For a planar, incompressible and Newtonian flow conditions these equations are, respectively:
Differential form:
Continuity Equation: ∂u∂x+∂v∂y=0
x-asix Momentum equation: ∂u∂t+u⋅∂u∂x+v⋅∂u∂y=(−1ρ).∂p∂x+γ.[∂2u∂x2+∂2u∂y2]
y-asix Momentum equation: ∂v∂t+u⋅∂v∂x+v⋅∂v∂y=(−1ρ).∂p∂y+γ.[∂2v∂x2+∂2v∂y2]
Integral form:
OpenFOAM uses the finite volume method in order to discretize the equations that are solved. OpenFOAM is used in the test cases, later on, so the discretization applied in OpenFOAM is discussed here. Because the finite volume method is used, all the parts of equations need to be specified as an integral over the volume of the cell. By using the Gauss theorem, these volume integrals can be converted to surface integrals. These surface integrals represent the fluxes through each cell. In order to solve the equations, the basic terms are linearized. These basic parts make up the set of equations needed to be solved. With the help of an implicit method (iteration is needed because the next value depends also on itself: yn+1=f(yn,yn+1) or an explicit method (in which the next values is determined from the previous values: yn+1=f(yn), the values for the next step will be calculated.
In order to discretize all the different parts of the equations, OpenFOAM gives the possibility to specify the discretization of every part of the conservation equations. With the careful study of the conservation equations and the derived equations in order to solve them, different types of basic equations can be found. By defining how these basic equations are discretized, all equations can be discretized by combining these essential parts. OpenFOAM uses a standard definition for every basic equation so that different variables can be filled in later on.
The above code shows the discretization schemes used for different parts of the governing equation used to obtain our numerical simulation. We have used icoFoam solver to discretize our governing equation and to achieve our numerical results.
GEOMETRY and MESH GENERATION
Now, to create our desired geometry, we are going to divide our domain into five individual blocks, it will give us the ease to change our geometry according to our mesh grading factor. The domain is divided into five blocks with respective vertices, as shown below:
To create geometry and to generate a mesh in OpenFOAM, we need to edit the BlockMeshDict file; it can be found under the system folder of our case tutorial ("cavity," in this case). BlockMeshDict file is modified to implement our geometry, and 0 folder is used to set the initial conditions. Several minor variations are done in other folders depending upon the need of the user and to satisfy the requirements of the chosen solver.
To apply boundary conditions, we need to broke the geometry into patches (regions), where each patch in the list has its name as the keyword, which is the choice of the user, although we should use something that conveniently identifies the patch, e.g.inlet (for inlet boundary condition); the name is used as an identifier for setting boundary conditions in the field data files. The BlockMeshDict file for a non-graded mesh with the appropriate patch name is written below:
/*--------------------------------*- C++ -*----------------------------------*
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 6
\/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) //0
(0.08 0 0) //1
(0.08 0.005 0) //2
(0 0.005 0) //3
(0.08 0.01 0) //4
(0 0.01 0) //5
(0.2 0.01 0) //6
(0.2 0.005 0) //7
(0.2 0 0) //8
(0.2 -0.01 0) //9
(0.08 -0.01 0) //10
(0 0 0.0001) //11
(0.08 0 0.0001) //12
(0.08 0.005 0.0001) //13
(0 0.005 0.0001) //14
(0.08 0.01 0.0001) //15
(0 0.01 0.0001) //16
(0.2 0.01 0.0001) //17
(0.2 0.005 0.0001) //18
(0.2 0 0.0001) //19
(0.2 -0.01 0.0001) //20
(0.08 -0.01 0.0001) //21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (120 20 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 14 3)
(14 16 5 3)
);
}
outlet
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
noSlipWalls
{
type wall;
faces
(
(15 17 6 4)
(16 15 4 5)
(12 11 0 1)
(20 21 10 9)
(21 12 1 10)
);
}
frontAndBack
{
type empty;
faces
(
(10 9 8 1)
(1 8 7 2)
(2 7 6 4)
(3 2 4 5)
(0 1 2 3)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
(14 13 15 16)
(11 12 13 14)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
The mesh is generated from a dictionary file named blockMeshDict located in the constant/polyMesh directory of a case. BlockMesh reads this dictionary, generates the mesh, and writes out the mesh data to points and faces, cells, and boundary files in the same directory. We can run BlockMesh function, to generate our mesh under our case folder, located in our run directory. We can easily change our grading factor by changing the values in the simpleGrading column, respectively. To view our generated mesh, we can paraFoam in our command line:
shivam@shivam-VirtualBox:~/OpenFOAM/shivam-6/run/blockmesh_Downdrill/cavity$ blockMesh
shivam@shivam-VirtualBox:~/OpenFOAM/shivam-6/run/blockmesh_Downdrill/cavity$ paraFoam
Before running the case, it is a good idea to view the mesh to check for any errors. The mesh is displayed in paraFoam, the post-processing tool supplied with OpenFOAM. The paraFoam post-processing is started by typing in the terminal from within the case directory. The figure below shows the geometry and our non-graded desired mesh (contains almost 6400 cells):
PHYSICAL MODEL-SETUP
After generating the mesh, now its important to describe the physical nature of our flow problem, in this section, we are going to define the physics of our problem. This section will contain three parts. In first, we will describe the physical properties of fluid, i.e., kinematic viscosity and other parameters, if required. In the second part, we will initialize our initial and boundary conditions. The last part will designate the appropriate value of the time step, satisfying our CFL conditions.
Specifying Physical Properties
In OpenFOAM, the physical parameters for a specific flow problem are described in the file called TransportProperties file. This file is located in the constant directory under our case file. In our case, we have assumed that our fluid is a Newtonian fluid, and the viscosity of fluid flow is given as 10−5m2/s. The respective TransportProperties file is written below(this file will be the same for all analysis with different grading factor) :
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-5;
// ************************************************************************* //
Specifying Tiemstep Value
While selecting numerical schemes to solve the discretized governing equations, the only accuracy is not enough. Our numerical scheme should be both stable and accurate. We say a numerical scheme is stable when truncation error does not increase in amplitude after each time step. So, there exist stability criteria that calculate the extreme values of the time step and space step for such numerical schemes to attain stability. For our problem statement, we use CFL ( Courant–Friedrichs–Lewy condition ) stability criteria to get our stability condition.
In OpenFOAM, input data relating to the control of time and reading and writing of the solution data are read in from the controlDict dictionary. For the end time, we wish to reach the steady-state solution where the flow is circulating around the cavity. As a general rule, the fluid should pass through the domain ten times to reach a steady-state in laminar flow. So, after calculation, we discover that 0.5s is sufficient, so we shall adopt this value. To specify this end time, we must specify the stopAt keyword as endTime and then set the endTime keyword to 0.5. Now we need to set the time step, represented by the keyword deltaT. To achieve temporal accuracy and numerical stability when running icoFoam, a Courant number of less than 1 is required. The Courant number is defined for one cell as:
Co=δt⋅|U|δx
where δt is the time step,|U| is the magnitude of the velocity through that cell, and δx is the cell size in the direction of the velocity. The flow velocity varies across the domain, and we must ensure Co<1 everywhere. We, therefore, choose δt based on the worst-case: the maximum Co corresponding to the combined effect of large flow velocity and small cell size. Here, the cell size is fixed across the domain, so the maximum Co will occur next to the lid where the velocity approaches 1ms−1. The cell size is:
δx=dn=0.00510=0.0005m
Therefore to achieve a Courant number less than or equal to 1 throughout the domain, the time step δt must be set to less than or equal to:
δt=Co⋅δx|U|=1⋅0.00051=0.0005s
We can conclude that there will be a different value of the time step for each mesh with different values of grading factor.
These are the values we have calculated for different values of grading factor satisfying our CFL conditions. Thus we need to change our control Dict file while changing the mesh; we will come to this later during our "Mesh refinement " section. Entries of a controlDict for a nongraded mesh dictionary are given below:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.5;
deltaT 0.0005 ;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Specifying Initial and Boundary Conditions
Governing equations are the same for every CFD problem, and then there should be something that makes our results unique for every flow problem. This is done by Boundary conditions which are unique for every CFD problem. We can specify our inlet-velocity and outlet-pressure condition in the respective notepad file located inside the 0 folder in our run-case directory.
These files will remain the same for every analysis of different mesh grading factor. The boundary conditions provided were as follows: a ‘constant velocity profile’ was assigned to the inlet face, ‘zero gradient’ was assigned to the outlet face, and ‘wall (no-slip)’ was assigned to both lower & upper wall faces. Only the front & back faces were designated as ‘empty.’
Initial and Boundary Velocity profile Conditions:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (1.5 0 0);
}
outlet
{
type zeroGradient;
}
noSlipWalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Initial and Boundary Pressure profile Conditions:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
noSlipWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
NUMERICAL SOLUTIONS
Till now, we have only discussed the physical nature of our problem (generation of mesh, specification of boundary conditions), but now we are looking forward to performing numerical simulation, to obtain our desired results. In the governing equation section, we already had discussed some parts of this section, i.e., discretization schemes involved in your governing equations. After discretization governing equations, we get a set of linear algebraic equations, which is then converged to our final results with some tolerance level using the finite volume method.
In OpenFOAM, this all done by pre-defined solvers, which can be found under the solvers' folders (this directory contains many solvers who are defined uniquely to solve only a particular type of problem). Usually, one problem can be solved by multiples solvers and with different solver parameters; however, to efficiently solve the problem, it is imperative to give the correct solver parameters and numerical schemes.
In our problem statement, we are going to use the solver named Icofoam. icoFoam solves the incompressible laminar Navier-Stokes equations using the PISO algorithm. The code is inherently transient, requiring an initial condition (such as zero velocity) and boundary conditions. The icoFOAM code can take mesh non-orthogonality into account with successive non-orthogonality iterations. The number of PISO corrections and non-orthogonality corrections are controlled through user input. After implementing our solver, we will get the desired numerical solution, which can be further viewed in our next post-processing step. The implementation of our solver in the command line is shown below:
shivam@shivam-VirtualBox:~/OpenFOAM/shivam-6/run/blockmesh_Downdrill/cavity$ icoFoam
POST_PROCESSING
Now, this is the most exciting and beautiful part of our CFD analysis. As soon as results are written to time directories, they can be viewed using paraFoam. The primary post-processing tool provided with OpenFOAM is ParaView, an open-source visualization application. paraFoam is strictly a script that launches ParaView, by default using the reader module supplied with OpenFOAM. The term paraFoam may thus sometimes be used synonymously for the OpenFOAM reader module itself. Like any OpenFOAM utility, paraFoam can be executed from within the case directory or with the case option with the case path as an argument.
To prepare paraFoam to display the data of interest, we must first load the data at the required run time of 0.5 s. If the case were run while ParaView was open, the output data in time directories would not be automatically loaded within ParaView. To load the data, the user should click Refresh Times in the Properties window. The time data will be loaded into ParaView. As the results, we need to obtain two things, first the velocity contour over the whole domain at the last step, and second is the plot of velocity's magnitude vs Y-axis near the step region.
Obtaining Final Velocity Contour
After opening the paraview successfully, First, click on the apply button, as shown in the first figure. Then set contours to show velocity and, at last, click on the last time step button to obtain the final velocity contour as shown in the second figure.
Obtaining a plot of Velocity near step region
At first, click on the Plot over the line button, as shown in the first figure. Then enter the appropriate endpoints of the line we wish to plot on, as shown in the second figure. At last, choose the velocity option from the plot variable option then provide the relevant name for the title and axis of the plot, as shown in the last figure.
MESH REFINEMENT
In our case analysis, we are dealing with laminar flow, so it's become essential to capture the boundary layer effect to get more accurate and physical results. A boundary layer is the layer of fluid in the immediate vicinity of a bounding surface where the effects of viscosity are significant. We also have no-slip boundary conditions at walls, so it becomes imperative to use more finer mesh near the walls, to encapsulate both the effects of boundary layer theory and no-slip boundary conditions. The process of changing mesh, according to the physical need of the problem, in order to produce more accurate results, is called Mesh Refinement.
We can make our mesh fine near the walls, either by increasing the number of cells in each block or by introducing the non-zero grading factors in the blockMeshDict file. Latter way is always preferred, as it is more efficient. Also, it gives more accurate results with a fewer number of cells than the former method, thereby decreasing the computational time. Grading factor can be defined by the formula shown below:
Grading factor=size of the end cellsize of the first cell
To observe the effect of the grading factor, we are going to take three values of grading factor, i.e., 0.2, 0.5, and 0.8. The complete analysis is performed three times again, each for each value of the grading factor. Now we will have a look at our new refined mesh, other results and observations are discussed in the last section.
Refined Mesh with 0.8 as grading factor
The desired grading factor can be easily introduced in the BlockMeshDict file. Shown below is the block file for 0.8 as the grading factor; a similar process can be done for other values of the grading factor.
Refined Mesh with 0.5 as grading factor
Refined Mesh with 0.2 as grading factor
RESULTS and CONCLUSIONS
In this last section, velocity and contour and plot of velocity near the step-region for different mesh will be discussed. At first, we will observe our results and later will compare them to make appropriate conclusions.
Results of non-graded mesh
Results of mesh with 0.8 as grading factor
Results of mesh with 0.5 as grading factor
Results of mesh with 0.2 as grading factor
Effects of graded Mesh:
CONCLUSIONS
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Unsteady simulation of Carreau fluid model for Pulsatile blood flow through a 3D Bifurcating Artery
CONTENT: Abstract. Introduction. Problem Specification. Geometry and Mesh Generation. Physical Model Set-up. Numerical Solution. Simulation and Results. Verification and Validation. Conclusion. ______________________________________________________________________________________________________________________________________________________________________________ …
05 Oct 2020 12:58 PM IST
Automated simulation of Hagen–Poiseuille Flow through a pipe using OpenFoam and MATLAB
CONTENT: Abstract. Problem Statement. A Brief Introduction to OpenFOAM. Theory and Governing Equations. MATLAB Scripts File. Geometry and Mesh Generation. Physical Model Set-up. Numerical Solution. Post-Processing and Results. Verification and Validation. Conclusion. …
29 Jul 2020 08:21 AM IST
Simulation of 2D laminar flow over Backward facing step using OpenFOAM
CONTENT: Abstract. Problem Statement. A Brief Introduction to OpenFOAM. Theory and Governing Equations. Geometry and Mesh Generation. Physical Model Set-up. Numerical Solution. Post-Processing. Mesh Refinement. Results and Conclusion. …
17 Jul 2020 11:21 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.