Computational fluid dynamics (CFD) is a branch of fluid mechanics that uses numerical analysis and data structures to analyse and solve problems that involve fluid flows. Computers are used to perform the calculations required to simulate the free-stream flow of the fluid, and the interaction of the fluid (liquids and gases) with surfaces defined by boundary conditions. With high-speed supercomputers, better solutions can be achieved, and are often required to solve the largest and most complex problems.
This post is a short overview of how CFD calculation is done using OpenFOAM software. Before reading this post, one should understand what are the steps involved in CFD. Do check out this post to know about CFD and the steps involved http://geniuserc.com/introduction-to-cfd-analysis-and-steps-involved/
What is OpenFOAM?
OpenFOAM is an open source CFD software which stands for Open Field Operation and Manipulation. OpenFOAM is based on C++ and is different compared to other commercial software like ANSYS fluent and SimScale in the sense that it is based on Command line instead of GUI. It can be quite difficult to transition from GUI based software to OpenFOAM for the first time. This post explains how OpenFOAM works and what are the major elements that form a problem case.
CFD process always starts with pre-processing where you model the problem into a geometry, use an appropriate mesh, and then solve the problem using an appropriate solver and finally postprocess the results. The process is the same in case of OpenFOAM, however, these processes are simply done by setting up case including simple text files. OpenFOAM just reads the text files that store all the required information of geometry, meshing, boundary conditions, discretization schemes, types of solver and so on.
To understand this, let us consider an example of a tutorial case of incompressible flow in a cavity which is solved by icoFoam solver. These tutorials can be found in the OpenFOAM installed directory. For example; C:\OpenFOAM\OpenFOAM-v2012\tutorials\incompressible\icoFoam\cavity\cavity.
Inside any case of OpenFOAM, there must be three files named as 0, constant and system.
0 refers to the initial condition or the values of parameters at time t=0. The initial values of each parameters along with the boundary conditions are assigned in the text files in the 0 folder. For the cavity case, the parameters are pressure(p) and velocity(U).
The values and boundary conditions are assigned in C++ as shown in figure below;
constant folder has the files that store the values of parameters that remain constant throughout the simulation process. In the example case of cavity, the constant folder has transport properties(i.e. viscosity). Also a folder named polymesh is also created inside constant folder which stores the mesh once it is created.
Inside the system folder, there are files that defines or controls overall simulation process. For the given example of cavity, the files inside the system folder are shown below;
blockMeshDict and PDRblockMeshDict defines the geometry and the mesh, controlDict defines the control for simulation like start time, end time, number of iterations, etc . Similarly, fvSchemes shows the discretization and interpolation schemes while the fvSolution specifies the type of solver used.
This post covered the general overview of any OpenFOAM case. As a beginner, you can go through different cases, check and read the files and try to understand the information stored in each files. More detailed posts related to OpenFOAM will be posted soon. Feel free to give your thoughts in comments.