numerical simulation of flow in lid-driven cavity using openfoam · 2018-10-12 · flows and roll...
TRANSCRIPT
INSTITUTE OF TECHNOLOGY, NIRMA UNIVERSITY, AHMEDABAD – 382 481, 08-10 DECEMBER, 2011 1
Abstract-- In recent years OpenFOAM solvers have attracted
great attention of the academia and industrial practitioners.
Principal potentialities of this software are full access to the
code, easy solver generation, modification and a huge and open
users community among others. The isothermal flow patterns in
lid-driven cavity for three different geometric configurations of
the cavity are obtained using OpenFOAM solvers. These
configurations include the square cavity, skewed cavity and
trapezoidal cavity. The steady flow patterns obtained by
OpenFOAM for different Reynolds numbers (Re) ranging from
100 to 3200 are compared with the benchmark published results
of Ghia et al. The isothermal flow in all the three cavities are
discussed in detail for varying Reynolds numbers.
Keywords--OpenFOAM, icoFoam, Lid-driven cavities, Stream
function, Vorticity.
I. INTRODUCTION
avity flows such as lid-driven cavity has served over and
over again as a model problem for testing and evaluating
numerical techniques. Lid driven cavity flows are
important in many industrial processing applications such as
short-dwell and flexible blade coaters. They also provide a
model for understanding more complex flows with closed
recirculation regions, such as flow over a slit, contraction
flows and roll coating flows. Cavity flows contain a full
range of flow types from pure rotation near the center of the
recirculation region to strong extension near the edges of the
lid. Numerical simulations of the 2D lid-driven cavity flow
are performed for a wide range of Reynolds numbers.
Accurate benchmark results are provided for steady solutions
as well as for periodic solutions around the critical Reynolds
number. The laminar incompressible flow in square, skewed
and trapezoidal cavities whose top wall (lid) moves with a
uniform velocity is studied here for Reynolds number range
of 100 to 3200. Results are available in the literature for this
problem using variety of solution methods [1]. The present
study of lid driven cavity for different geometric
configurations is mainly aimed to demonstrate the utility of
OpenFOAM CFD solver. The procedure to use OpenFOAM
for solution of isothermal flow in variety of geometric
configurations is demonstrated in this work.
II. OPENFOAM SOLVER
PENFOAM (Open Field Operation and Manipulation)
CFD Toolbox is a free, open source CFD software
package produced by a commercial company; OpenCFD
Ltd. OpenFOAM is a free source CFD package written in
C++ which uses classes and templates to manipulate and
operate scalar, vectorial and tensorial fields[2]. Thus,
OpenFOAM can interpret the true meaning of a field,
encapsulating the idea of magnitude and direction of a vector.
Combined with implementations of adequate numerical
methods to the discretization of partial differential equations
and to the solution of the resulting linear systems,
OpenFOAM is a good choice to handle CFD problems. Besides, its open-source characteristic is an advantage in the
implementation of any addition or modification in the code.
OpenFOAM gives a flexible framework which combines all
the required tools for solving any CFD problem. This
framework consists of enormous groups of libraries for
different mathematical, numerical and physical models.
Linking the mathematical and numerical tools with the
physical models in a main C++ function produces different
solvers and utilities. It has a large user base across most areas
of engineering and science, from both commercial and
academic organizations. The discretization of the flow
governing equations in OpenFOAM is based on the finite
volume method (FVM) formulated with collocated variable
arrangement, with pressure and velocity solved by segregated
methods. SIMPLE (Semi-implicit Method for Pressure
Linked Equations) or PISO (Pressure Implicit Splitting of
Operators) are used for pressure–velocity coupling. SIMPLE,
SIMPLER, SIMPLEC, and PISO are the most widely used
algorithms to pressure–velocity coupling. The software also
offers a wide range of interpolation schemes, solvers and pre-
conditioners for the discretized algebraic equation system.
OpenFOAM has an extensive range of features to solve
anything from complex fluid flows involving chemical
reactions, turbulence and heat transfer, to solid dynamics and
electromagnetic. Almost everything (including meshing, and
pre- and post-processing) runs in parallel as standard.
OpenFOAM offers complete freedom to customise and
extend its existing functionality and gives support from
OpenCFD. It follows a highly modular code design in which
collections of functionality (e.g. numerical methods, meshing,
physical models) are each compiled into their own shared
library. Executable applications are then created that are
simply linked to the library functionality. There are many
recent contributions in implementing different solvers and
physical models in OpenFOAM. OpenFOAM, undoubtedly,
opens new horizons for CFD community for efficient models
devolving, allowing the industrial sectors to be updated with
Numerical Simulation of Flow in Lid-driven
Cavity using OpenFOAM
A. Jignesh P. Thaker and B. Jyotirmay Banerjee
A. M.Tech (Turbomachines), Department of Mechanical Engineering, SVNIT, Surat.
B. Associate Professor, Department of Mechanical Engineering, SVNIT, Surat.
C
O
INTERNATIONAL CONFERENCE ON CURRENT TRENDS IN TECHNOLOGY, ‘NUiCONE – 2011’ 2
all new models without any delay for waiting the new models
to be implemented in the commercial CFD codes.
OpenFOAM includes over 80 solver applications that
simulate specific problems in engineering mechanics and
over 170 utility applications that perform pre- and post-
processing tasks, e.g. meshing, data visualisation, etc. One of
the strengths of OpenFOAM is that new solvers and utilities
can be created by its users with some pre-requisite knowledge
of the underlying method, physics and programming
techniques involved. OpenFOAM is supplied with pre- and
post-processing environments. The interface to the pre- and
post-processing are themselves OpenFOAM utilities, thereby
ensuring consistent data handling across all environments.
The overall structure of OpenFOAM is shown in Fig.1.
Fig.1. Overview of OpenFOAM structure.
III. PROCEDURE FOR SOLUTION OF DIFFERENT CAVITIES IN
OPENFOAM
The present section is a discussion on how to pre-process,
run and post-process the isothermal, incompressible flow in a
two dimensional square domain using OpenFOAM. The three
geometric configurations considered for simulation in this
work are shown in Fig.2.[6] For square cavity, all the
boundaries of the square are walls. The top wall moves in the
x-direction at a constant speed while the other 3 are
stationary. The flow is assumed to be laminar and is solved
on a uniform mesh using the icoFoam solver for laminar,
isothermal, incompressible flow.
Fig.2. Geometry of square, skewed and trapezoidal cavity.
The whole process is categorised in three steps.
1) Pre-processing
First a directory is created for this case and given a name
as square cavity in the directory of OpenFOAM. It needs
three directories; initialize, constant and system. In initialize
the starting condition for properties of the fluid are provided.
In constant directory there are two subdirectory; polyMesh
and transport properties. PolyMesh contains blockMesh and
boundary case files. Now the code for geometry of square
lead driven cavity in OpenFOAM need to be written and
saved in to blockMesh file. Editing of files is possible in
OpenFOAM. 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. In OpenFOAM this data is stored in a set
of files within a case directory rather than in a single case
file. This code being simulated involves data for mesh, fields,
properties, control parameters, etc.
For generating mesh it should have command of
blockMesh. Run blockMesh command in terminal window so
OpenFOAM created mesh in square domain. Any mistakes in
the blockMeshDict file are picked up by blockMesh and the
resulting error message directs to the line in the file where the
problem occurred. There should be no error messages at this
stage. For checking mesh it is required to write the command
checkMesh in terminal window. Then it shows mesh size,
number of cells, number of faces, patches, etc. Once the mesh
generation is complete, then look at this initial fields set up
for this case. The case is set up to start at time t = 0, so the
initial field data is stored in a initialise directory means 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.
For this case of cavity, the boundary consists of walls only,
split into two patches named: fixedWalls for the fixed sides
and base of the cavity; movingWall for the moving top of the
cavity. 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, 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 front and Back patch. The
other patches are walls: a no-slip condition is assumed on the
fixed Walls, hence a fixedValue condition with a value of
uniform (0 0 0). The top surface moves at a speed of 1 m/s in
the x-direction so requires a fixedValue condition also but
with uniform (1 0 0).
The physical properties for the case are stored in
dictionaries. For an icoFoam case, the only property that must
be specified is the kinematic viscosity which is stored from
the transport Properties dictionary. Check that the kinematic
viscosity is set correctly by opening the transport Properties
dictionary to view or edit its entries. The keyword for
kinematic viscosity is nu, the phonetic label for the Greek
symbol by which it is represented in equations. Initially this
case is run with a Reynolds number of 100, where the
Reynolds number is defined as,
INSTITUTE OF TECHNOLOGY, NIRMA UNIVERSITY, AHMEDABAD – 382 481, 08-10 DECEMBER, 2011 3
where d and U are the characteristic length and velocity
respectively and is the kinematic viscosity.
Input data relating to the control of time are read from the
control dictionary. For viewing this file; as a case control file,
it is located in the system directory. The start and stop times
and the time step for the run must be set. OpenFOAM offers
great flexibility with time. To start the run from time t=0
means OpenFOAM needs to read field data from a directory
named 0. Therefore it is required to set the startFrom
keyword to startTime and then specify the startTime keyword
to be 0. The end time is to reach the steady state solution. As
a general rule, the fluid should pass through the domain 10
times to reach steady state in laminar flow. In this case the
flow does not pass through this domain as there is no inlet or
outlet, so instead the end time can be set to the time taken for
the lid to travel ten times across the cavity. In fact, with
hindsight, we discover that 15 s is sufficient so adopt this
value. To specify this end time, it must specify the stopAt
keyword as endTime and then set the endTime keyword to
15. Now it needs 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:
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 it must
ensure Co < 1 everywhere. Therefore choose δt based on the
worst case: the maximum Co corresponding to the combined
effect of a 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 1 ms−1.
The cell size is:
Here for this geometry d=1 and number of grids are
129x129. Thus δx becomes 0.007752 and δt becomes
0.007752 by Courant number definition. The δt is take as
0.005 for stability in these computations. As the simulation
progresses to write results at certain interval of time that can
later be view with a post-processing package, the
writeControl keyword presents several options for setting the
time at which the results are written. Here it is required to
select the timeStep option which specifies that results are
written every nth time step where the value n is specified
under the writeInterval keyword.
Now it is required to specify the choice of finite volume
discretisation schemes in the fvSchemes dictionary in the
system directory. The specification of the linear equation
solvers, tolerances and other algorithm controls is made in the
fvSolution dictionary, similar to the in the system directory.
In a closed incompressible system such as the cavity, pressure
is relative: it is the pressure range that matters not the
absolute values. In cases such as this, the solver sets a
reference level by pRefValue in cell pRefCell.[2] In this
example both are set to 0. Changing either of these values
will change the absolute pressure field, but not, of course, the
relative pressures or velocity field.
To see the mesh of square domain then before the case is
run it is a good idea to view the mesh to check for any errors.
The mesh is viewed 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 paraFoam. This launches paraview window and in
that see the domain how it looks and also see the mesh.
2) Processing
OpenFOAM applications can be run in two ways: as a
foreground process, i.e. one in which the shell waits until the
command has finished before giving a command prompt; as a
background process, one which does not have to be
completed before the shell accepts additional commands.
Here, it is required run icoFoam in the foreground. The
icoFoam solver is executed by entering the case directory and
typing icoFoam in the terminal window. It tells the current
time, maximum Courant number, initial and final residuals
for all fields in terminal window. It should also calculate the
stream function and vorticity values at each and every time
steps.
3) Post-processing
As soon as results are written to time directories, they can
be viewed using paraFoam. One should return to the
paraFoam window and select the Properties panel for the
cavity. OpenFOAM case module. In paraView the pressure,
velocity, stream function and vorticity contours can be
visualised.
IV. RESULTS AND DISCUSSION
The numerical simulations for isothermal flow for square,
skewed and trapezoidal cavity are carried out using the CFD
solver OpenFOAM. Results are generated for various
Reynolds number to observe the influence on stream line and
vorticity patterns in the cavity. The influence of grid size on
flow distribution is also discussed. In this section first the
validation of the numerical results are depicted. This is
followed by discussion on flow inside the square cavity. The
influence of Reynolds number on flow is elaborated. The
flow pattern in the skew cavity and the trapezoidal cavity are
discussed then for varying values of Reynolds number.
1) Validation
First, the results obtained by OpenFOAM solver are
compared with the benchmark results for square cavity
presented by Ghia et al. [1]. Fig. 3 and Fig.4 show the
contours of streamline and vorticity generated by
OpenFOAM for square cavity for a grid size 129x129 for
Re=100. These results are compared benchmark result
obtained by of Ghia et al.[1] . The figures on the left are
results obtained by OpenFOAM and those on the right are
from Ghia et al. [1]. The values of the stream function and
vorticity obtained by OpenFOAM are exactly comparable to
results obtained by Ghia et al. [1]. To get a better picture
Table I and II provides the exact values of stream function
(ψ) and vorticity [5].
INTERNATIONAL CONFERENCE ON CURRENT TRENDS IN TECHNOLOGY, ‘NUiCONE – 2011’ 4
Fig.3. Comparison of streamline values for Re=100 with results of Ghia at
al.[1] (129x129)
TABLE I
VALUES OF STREAMLINES CONTOURS FOR SQUARE CAVITY
Fig.4. Comparison of vorticity values for Re=100 with results of Ghia at
al.[1] (129x129). TABLE II
VALUES OF VORTICITY FOR ALL CAVITIES
Fig.5. Streamlines and vorticity contours for Re=400 (129x129) of square
cavity plotted with OpenFOAM.
Fig.6. Streamlines and vorticity contours for Re=1000 (129x129) of square
cavity plotted with OpenFOAM.
Fig.7. Streamlines and vorticity contours for Re=3200 (129x129) of square
cavity plotted with OpenFOAM.
Fig.8. Streamlines and vorticity contours for Re=400 (257x257) of square
cavity plotted with OpenFOAM.
INSTITUTE OF TECHNOLOGY, NIRMA UNIVERSITY, AHMEDABAD – 382 481, 08-10 DECEMBER, 2011 5
2) Square Cavity
The influence on lid motion to the flow pattern in the
cavity for lid-driven square cavity is discussed in this sub-
section. Fig 3, 5, 6and 7 show the contours of streamlines and
vorticity for Re=100, 400, 1000 and 3200 inside the lid
driven square cavity. It is observed that as Re increases from
100 to 3200, the secondary vortices start developing and
getting larger in magnitude. The center of the primary vortex
is towards the top right corner for lower values of Reynolds
number. It moves towards the geometric center of the cavity
with the increase in Re. All secondary vortices appear
initially very near the corners and its center shifts towards the
cavity center as Re increases. As Re increases, several
regions of high velocity gradients, indicated by concentration
of the vorticity contours, appear within the cavity. It is
observed that these regions are not aligned with the geometric
boundaries of the cavity. At a very high Reynolds number
secondary vortices are observed even at the upper left corner
Figure 7 shows the stream lines and vorticity contours
observed for Re=3200. Figure 8 shows the influence of grid
size on the flow pattern distribution for Re=400.
3) Skewed Cavity
The procedure mentioned above is followed for obtaining
the isothermal flow inside the skewed cavity. The skewed
cavity is inclined at 45º with respect to x-axis [6]. Length L1
and L2 are the dimensions of the skewed cavities, and β =45º
is the skew angle as shown in Fig2. The variation of
streamlines and vorticity contours due to the inclination are
discussed in this section.
Fig.9. Streamlines and vorticity contours for Re=100 of skewed cavity
plotted with OpenFOAM.
Fig.10. Streamlines and vorticity contours for Re=1000 (of skewed cavity
plotted with OpenFOAM.
Fig.9 and Fig.10 show the streamlines and vorticity
contour plots inside the skewed cavity at Re=100 and 1000
respectively. As Re increases from 100 to 1000, the
secondary vortices start developing at left corner of the cavity
and grow larger in magnitude. All secondary vortices appear
initially very near the left corners but when Re increases
vortices shifts towards the cavity center. To get a better
picture Table III provides the exact values of stream function
(ψ) for skewed cavity. TABLE III
VALUES OF STREAMLINES CONTOURS FOR SKEWED CAVITY
4) Trapezoidal Cavity
A trapezoidal cavity of general shape is given by the
location of the vertices and is represented here by E( ),
F(( , G( ) and H( ), Where =
and as shown in Fig.2.[6].
Fig.11. Streamlines and vorticity contours for Re=100 of trapezoidal cavity
plotted with OpenFOAM.
INTERNATIONAL CONFERENCE ON CURRENT TRENDS IN TECHNOLOGY, ‘NUiCONE – 2011’ 6
Fig.12. Streamlines and vorticity contours for Re=400 of trapezoidal cavity
plotted with OpenFOAM.
Fig.11 and Fig.12 depict the streamlines and vorticity
contour plots inside the trapezoidal cavity for Re=100 and
400 respectively. As Re increases from 100 to 400, the
secondary vortices start developing from bottom of the cavity
and grow larger in magnitude and shifts towards the cavity
center. The values of the stream function (ψ) in the cavity are
tabulated in Table IV. TABLE IV
VALUES OF STREAMLINES CONTOURS FOR TRAPEZOIDAL CAVITY
V. CONCLUSION
Steady flow analysis of the lid-driven square cavity shows
the existence of secondary vortices at the corners of the
cavity. The strength of the vortices increases as Reynolds
number increases. The obtained results from OpenFOAM
solver compared with available results of Ghia et al. [1]. The
steady state results of lid-driven square cavity are obtained
for Re = 100, 400, 1000 and 3200 using OpenFOAM. Also
the isothermal flow inside lid-driven skewed and trapezoidal
cavities for Re = 100, 400 and 1000 are discussed in terms of
streamline patterns and vorticity contours.
VI. REFERENCES
[1] U.Ghia, K. N. Ghia, and C. T. Shin, “High-Re Solutions for
Incompressible Flow Using the Navier-Stokes Equations and a
Multigrid Method”, Journal of Computational Physics, vol. 48, pp. 387-
411, January 1982.
[2] OpenFOAM, OpenFOAM user guide, 2010.
[3] W. D. McQuain, C. J. Ribbens, C. Y. Wang, and L. T. Watson, Steady
Viscous Flow in a Trapezoidal Cavity, Comput. Fluids, vol. 23, pp.
613–626, 1994.
[4] A. Sharma and V. Eswaran, A Finite Volume Method, in K. Muralidhar
and T.Sundararajan (eds.), Computational Fluid Flow and Heat
Transfer, chap. 12, Narosa, New Delhi, 2003.
[5] O. Bottela and R. Peyret, “Benchmark spectral results on the Lid-
Driven Cavity flow”, Computers & Fluids, vol.27, No.4, pp. 421-433,
1998.
[6] Sachin B. Paramane and Atul Sharma, “Consistent Implementation and
Comparison of FOU, CD, SOU, and QUICK Convection Schemes on
Square, Skew, Trapezoidal, and Triangular Lid-Driven Cavity Flow”,
Numerical Heat Transfer, Part B, vol.54, pp. 84-102,2008.