Saturday, October 13, 2012

OpenFOAM - BASICS



             CFD - Computational Fluid Dynamics is a branch of fluid mechanics that uses numerical methods to solve and analyze problems related to fluid flows. More information on CFD can be found on the Wikipedia page. There are many CFD software available in the market but OpenFOAM is an open source CFD toolbox so it is free of cost and also provides accurate results on par with many of the commercial CFD software.
The only drawback that many users feel is the lack of GUI and no support for windows (ya works only on Linux). Another thing that i felt is that it would be really helpful if someone provided with some basic tutorials to start of with, so this post is mainly based on the basic stuff needed to get started with OpenFOAM. From now on the text highlighted in grey are that commands to be typed in the terminal.


The installation details can be found on http://www.openfoam.org/download/. To check if it is installed correctly type icoFoam -help in the terminal window. If the "Usage" message appears then it is installed correctly.

There are a lot of examples provided in the OpenFOAM package itself but still understanding it might take some time. The tutorials can be found in the home folder if you have done all the steps provided in the installation page of the OpenFOAM website. Now type the following in the terminal window:
cd $FOAM_RUN/tutorials
ls
Now a list of the content of the tutorials folder is shown


These folder name refer to the type of problem that is implemented. A tutorial based on icoFoam solver can be found in the User Guide. So i'll be starting with another one. Now go to the Forward Step problem which is located in compressible/sonicFoam/laminar/

cd compressible/sonicFoam/laminar/forwardStep
Now you can see that this folder consists of three folders named:
  • 0: The 0 folder consists of the initial conditions and the boundary condition of the problem.
  • constant: The constant folder consists of the parameters that are kept constant throughout the simulation like viscosity , molecular weight, etc. Within the constant folder there is another folder named polymesh  which contains the geometry of the body that is to be simulated. The blockMeshDict file contains the in formation regarding the geometry. blockMesh is the most commonly used utility in OpenFOAM used for meshing.
  • system: The system folder consist of the time information like Start time, Stop Time, Time Interval etc.,
I'll describe each of the files associated in detail later but for now lets see how to run this example program.
The first thing to do is to mesh, this is done by using the blockMesh utility. So, now type blockMesh in the terminal window. (make sure you are in the forwardStep folder and not in constat or 0 or system folders)


If the meshing is successful the End command should appear, if there is an error in the bolckMeshDict file in the constant/polyMesh folder an error shows up. The checkMesh utility inspects the mesh and gives the information about the mesh like the number of points, faces, patches used, etc., if the mesh is good it returns a " Mesh OK" dialogue in the end.


After meshing run the solver i.e. type sonicFoam
sonicFoam is a Transient solver for trans-sonic/supersonic, laminar or turbulent flow of a compressible gas.(The list of the solvers can be found in the users guide)


The end time is specified 10 you can see that the solver stops computing after that specified time is reached. sonicFoam

To view the results a third-party software ParaView is used. Now to view the computed result type paraFoam or optirun paraFoam (see http://timepass-backwas.blogspot.in/2012/10/bumblebee-nvidia-optimus-technology-in.html to know what optirun does). The following screen appears


Now click apply (green color button in the left toolbar)


Now you can see the geometry. Explore and try to get used to the paraview software. Select Wireframe in the drop-down menu where "Surface" is selected in the above figure to view the mesh. To see the velocity and pressure values select the respective form the drop-down menu where "Solid Color" is selected at present and press the play button to see the variation of the values with time

Figure showing the velocity over the surface. Search for color maps and legend and try to modify according to your preference.


Figure showing the pressure profile over the surface. The above two figures show results at 10 sec.


    No comments :

    Post a Comment