Week 8 - Simulation of a backward facing step in OpenFOAM
Question :
In this challenge, you are going to simulate an incompressible-laminar-viscous flow through the backward facing step geometry. You should perform a transient simulation. The solver can be chosen based on the described physics of the flow. You need to explain the entire simulation procedure (how you set up the case). You should also provide explanations to every change you make inside the reference case files obtained from OpenFOAM tutorials. You can choose the inlet velocity shuch that the flow is laminar.
After that, you will perform 2 case studies as described below and compare the results.
Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)
Case 2 - Simulate the flow with grading factor of 0.2. The cells should be finer near the walls (includig the step wall).
You can use the following mesh parameters but you can feel free to modify these values.
Mesh specification
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the longer y direction = 20;
Boundary condition specification
The domain specifications are provided in the following figure.
Desired output
- Measure the velocity profile at 0.085 m from the inlet of the geometry for both case studies and compare. You can use the plot over line tool for this.
- Explain why Grading/Growth factor is essential for meshing.
`
Answer :
reynolds number(Re)
Ther reynolds number(Re) is a dimensionless number used in fluid mechanics and fluid dynamics to predict the behavior of fluid flow in different situations.
The formula for calculating the Reynolds number is:
`Re =(rho vd)/u`
Where :
Re is the Reynolds number.
`rho` (rho) is the density of the fluid.
v is the velocity of the fluid relative to an object or within a conduit.
d is a characteristic linear dimension of the object or conduit (e.g., the diameter of a pipe).
u (mu) is the dynamic viscosity of the fluid.
The interpretation of the Reynolds number is as follows:
If Re<2,000, the flow is typically laminar. In laminar flow, the fluid moves in smooth, parallel layers with minimal mixing.
If 2,000<Re<4,000, the flow is in a transitional state, and it can exhibit characteristics of both laminar and turbulent flow. The exact behavior depends on the specific conditions.
If Re>4,000, the flow is generally turbulent. In turbulent flow, the fluid moves chaotically with eddies and swirls, resulting in a high degree of mixing and increased friction.
Incompresible laminar viscous flow
Incompresible laminar viscous flow refer to a specific type of fluid in which the fluid is incompressible (density remains constant) and flows smoothly and predictably in layers,known as laminar flow. Additionally this type of flow accounts for the effects of fluid viscosity which cause the fluid to resist deformation and create friction between layers.
ANS
The geometry is 20 cm long and and there is a step halfway along the length of the geometry.
To construct this geometry, lets provide a thickness along the z-direction.
The boundary names are specified at the domains.
To access the file, follow the given procedure.
In the command line, type tut. This will direct you to the tutorials folder in openFOAM.
- In the tutorials folder,type in ls. This will list down all folders in tutorials.
- Type in cd incompressible. This will direct you to the incompressible folder, from which you can select the desired solver to solve the backward step.
- Copy the folder from the tutorial folder to the run folder,where we will make changes and execute the program.
- Once the folder is copied into the run folder, sufficient changes are made to the existing files so as to achieve the desired results.
Description of files inside the folder
-->Preprocessing
Cases are setup in OpenFOAM by editing case files. Users should select an editor of choice with which to do this, such as emacs, vi, gedit, nedit, etc. Editing files is possible in Open-FOAM because the I/O uses a dictionary format with keywords that convey sufficient meaning to be understood by the users.
-->Meshing
OpenFOAM always operates in a 3 dimensional Cartesian coordinate system and all geometries are generated in 3 dimensions. OpenFOAM solves the case in 3 dimensions by default but can be instructed to solve in 2 dimensions by specifying a ‘special’ empty boundary condition on boundaries normal to the (3rd) dimension for which no solution is required. The domain consists of 0.2 m length domain with a step at halfway along the length of the domain.
Since the flow velocity is assumed to be constant along z-direction,we only consider blocks along the 2D case. SInce a block is a 3D entity, there will be 8 vertices
Assuming that vertex 0 is the origin with entries(0,0,0). The other vertices can be plotted as such.
In the next step, the blocks needed to be specified. The type of mesh used is hexahedral. Inside the hex command, we have to specify vertices. The order of specification is to specify the vertices in the backface and frontface in counterclockwise direction. Next to the vertex nos, we define the number of divisions spaced along the co-ordinate axes. The simpleGrading command is used to specify whether a mesh is coarse or finer by defining expansion ratio which is the ratio of the width of the end cell to that of the start cell. Once the blocks are specified, the boundaries like the inlet and outlet are specified. Note that for specifying the boundary vertex, the back face is specified in the clockwise direction and the front face is specified in the counteclockwise direction.
A mesh of grading factor 1 and grading factor 0.2 is used as the two cases. The blockmesh is used to generate the mesh using the file blockMeshDict
blockMesh for gf =1




The file first contains header information in the form of a banner (lines 1-7), then file information contained in a FoamFile sub-dictionary, delimited by curly braces ({...}). For the remainder of the manual: For the sake of clarity and to save space, file headers, including the banner and FoamFile sub-dictionary, will be removed from verbatim quoting of case files. The file first specifies coordinates of the block vertices; it then defines the blocks (here, only 1) from the vertex labels and the number of cells within it; and finally, it defines the boundary patches.
The mesh is generated by running blockMesh on this blockMeshDict file. From within the case directory, this is done, simply by typing in the terminal: blockMesh
The running status of blockMesh is reported in the terminal window. Any mistakes in the blockMeshDict file are picked up by blockMesh and the resulting error message directs the user to the line in the file where the problem occurred. There should be no error messages at this stage.
Boundary and initial conditions
Once the mesh generation is complete, the user can look at this initial fields set up for this case. The case is set up to start at time t = 0 s, so the initial field data is stored in a 0 sub-directory of the cavity directory. The 0 sub-directory contains 2 files, p and U, one for each of the pressure (p) and velocity (U) fields whose initial values and boundary conditions must be set.
p


U




internalField -->the internal field data which can be uniform, described by a single value or nonuniform, where all the values of the field must be specified
boundaryField -->the boundary field data that includes boundary conditions and data for all the boundary patches
For the above case, the boundary consists of noslip wall.
As walls, both are given a zeroGradient boundary condition for p, meaning “the normal gradient of pressure is zero”. The frontAndBack patch represents the front and back planes of the 2D case and therefore must be set as empty. In this case, as in most we encounter, the initial fields are set to be uniform. Here the pressure is kinematic, and as an incompressible case, its absolute value is not relevant, so is set to uniform 0 for convenience. The boundary field for velocity requires the same boundary condition for the frontAndBack patch.
Physical Properties
The physical properties for the case are stored in dictionary files in the constant directory. For an icoFoam case, the only property that must be specified is the kinematic viscosity which is stored from the transportProperties dictionary. The user can check that the kinematic viscosity is set correctly by opening the transportProperties dictionary to view/edit its entries. The keyword for kinematic viscosity is
Control
Input data relating to the control of time and reading and writing of the solution data are read in from the controlDict dictionary. The user should view this file; as a case control file, it is located in the system directory.The start/stop times and the time step for the run must be set. OpenFOAM offers great flexibility with time control.
Contorl system


Now we need to set the time step, represented by the keyword `delta t`
To achieve temporal accuracy and numerical stability when running icoFoam, a Courant number of less than 1 is required.
Courant no is defined as C=
-->Running an application
openFOAM applications can be run either in the foreground or in the background. We will run icoFoam in the command line. The progress of the job is written to the terminal window. It tells the user the current time, maximum Courant number, initial and final residuals for all field.
-->Post-Processing
As soon as results are written to time directories, they can be viewed using paraFoam. Return to the paraFoam window and select the Properties panel for the cavity.OpenFOAM case module. If the correct window panels for the case module do not seem to be present at any time, please ensure that: cavity.OpenFOAM is highlighted in blue; eye button alongside it is switched on to show the graphics are enabled. 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 was run while ParaView was open, the output data in time directories will not be automatically loaded within ParaView. To load the data the user should uncheck Cache Mesh and click Refresh Times at the top Properties window (scroll up the panel if necessary). When The time data will be loaded into ParaView. In order to view the solution at t = 0.5 s, the user can use the VCR Controls or Current Time Controls to change the current time to 0.5.
Pressure

Velocity

Graph at 8.5 distance

For grading factor 0.2
The only change neededto be made in the blockmesh file is that in the blocks heading by changing the grading factor appropriately.



pressure

velocity

Graph at 8.5 m length

Comparing the above two graphs, we can infer that the profile is sharp for fine meshing with grading factor of 0.2. Hence grading factor is important in CFD where we needed to get accurate results.