CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Calculate aerodynamic coefficients with openfoam using only opensource programs (

Xwang August 4, 2009 05:16

Calculate aerodynamic coefficients with openfoam using only opensource programs
Hi to all,
I'm studying openFOAM to use it to calculate aerodynamic coefficients (forces and moments) of complete air-crafts (subsonic, transonic and supersonic studies) and vehicles for steady state simulation.
I want to use only open source programs so I've thought the following procedure:
1) create an stl 3d model using Varkon
2) create a mesh using SnappyHexMesh from the stl model
3) define boundary conditions and solver parameters
4) run the simulation till convergence has been reached
5) check the results using paraview
6) check the results plotting aerodynamic coefficients versus simulation step to be sure that even the coefficients have converged
I have the following questions:
a) Do you agree with such method? Is it feasible
b) I've seen that SnappyHexMesh can be unreliable on sharp edges. Is it better to use a different mesh tool?
c) What kind of solver do you suggest to use considering that initially I would like to learn a pretty general usable solver for all the cases which should be able take in account also the boundary layer around the geometry?
d) How can I compute force and moment coefficients?
e) How can I set up simulation so that it stops calculation when simulation has been reached?
6) How can I plot the graph of point 6?
Thank you for you help,

franzisko August 4, 2009 09:55

I am interested in your work style... I am not so skilled to give important suggestions, but I would use blender instead of varkon. I cant calculate force coefficients and I would be interested in doing too,
bye, F.

Xwang August 20, 2009 15:06

Hi to all!
Which solver do you suggest for these kind of steady state calculation?
Moreover can you suggest some book or documentation related to solvers, turbulence model and boundary and initial conditions?
Thank you,

Xwang August 23, 2009 05:30

Can you help me, please?
Is this the correct section or should I post in the Running/Solving one?
Thank you,

fra76 August 24, 2009 13:29

Hi Xwang,
what you can do is perfectly feasible. I can't use blender, but as far as I know it should be possible to create geometries with it and save them as STLs (ascii, so patch names are preserved).

snappyHexMesh is not able to capture sharp edges, but if you refine enough this can be more an aesthetic issue than having a big effect on the solution. You can try different settings and look at the mesh in paraFoam.

Then, you need a different solver for each specific kind of flow (i.e, subsonic, transonic, supersonic). The solver changes if you want to run steady state or transient, but I guess you want to solve your geometries steady state. For example, for turbulent, incompressible subsonic flows you can use simpleFoam, or you can modify it to match your needs. Have a look to the user guide to find the right solver for each case.

About force coefficients, the right tool is the forceCoeffs function object (you can find the source code in src/postProcessing/functionObjects/forces/forceCoeffs). You should be able to find some tutorials where this function object (or the one for computing the forces only) is used. Otherwise search the forum for some example.
The function object will print down the coefficient at regular interval, so that you will be able to plot and monitor the convergence as well.

Stopping the solution when it reaches a coverged state is more tricky. Probably you should implement something yourself, that check a convergence criterion and stops iterating.

As you can see, all the tools are there!

Hope this helps,

Xwang September 27, 2009 05:03

Hi to all!
Since I've found that Blender has a limited precision and limited geometry maximum size, I'm searching for a different tool to create the geometry. So I've discovered that gmsh is not only a mesher but also has some CAD featureas and so I wonder if someone uses it also to create the geometry and if it can be used as an open source alternative to gambit.
Thank you,

linnemann September 27, 2009 06:30


If I were you I would look into the possibilities of the Salome platform.

Xwang September 27, 2009 06:34


Originally Posted by linnemann (Post 230637)

If I were you I would look into the possibilities of the Salome platform.

I've seen it, but it seems much more complicated than gmsh (probably because it has much more capabilities which I think I don't need since I need only a tool to create a 3d geometry).
Moreover I don't think it is so easy to install on my kubuntu 9.04 amd64 distro.

linnemann September 27, 2009 06:43

I use it to create geometries like 2d airfoils, propeller blades and rear ship geometries/mesh.

I've tried most of the open-source mesh programs out there and Salome is bar far the most capable right now.

The features are much like Gambits with a better CAD module.

I don't think you will run into much trouble installing it on Ubuntu since the Salome download is almost self contained with regards to dependencies.

I use the Debian 64 bit version on CentOS 5.3 64bit and it all works great.


jms March 16, 2011 12:13

Dear all,

I am using this function that it is needed in controlDict in orer to get the lift, drag and moment coefficients for a computation of the flow around an airfoil. The results I get for the lift and drag coefficients are very good compared to the reference I am using for both lift and drag coefficients but they are very bad for the moment coefficients. I use CofR=0.25*chord.
Any idea why I am getting this bad results?



Greg Givogue April 24, 2011 11:02

Hi Jose,

Have you determined why your moment calculations are different?

I am attempting to use the moment/forces data from OpenFOAM to determine the Centre of Pressure on a 3 D body but I am getting CP values that aren't located anywhere near the body...


jms April 24, 2011 14:46

Hi Greg,

I haven´t determined yet why the moment coefficient calculation is wrong. If you get to something let me know,please!



Greg Givogue April 24, 2011 15:31

I haven't figured it out yet - I have posted this question in the post-pro section of the forum...

I'm going to check the OpenFOAM results using Tecplot. I will post my findings at the above link.


Xwang June 18, 2011 05:43

Hi to all,
after two years I finally manage to start my project.
So I renew my original questions and add some new ones:
1) is the commercial use of OpenFOAM free?
2) in substitution of Varkon, I will use FreeCAD ( . Is some one using it to draw the 3d model?
3) since I need to refresh my university studies (I graduated seven years ago), I would like to know if you can suggest me some good CFD books? I've seen in the OpenFOAM wiki page a link to a PhD course which suggests the Versteeg and Malalasekera book. Is it a good one? Is there any other which fit better with OpenFOAM?
4) is ther any way to avoid to add the " source /opt/openfoam200/etc/bashrc" line to the bashrc file? I would like to maintain my desktop environment unchanged, so maybe I can avoid to modify the bashrc file by creating some bash scrips which first execute the source command and then call the original OpenFOAM command. Any idea?
Thank you,


cece84 August 29, 2011 12:58

How to read coefficients ?

i would like to calculate Cd and Cl around an airfoil. I added the script i found on some websites in the ControlDict file but i don't know how to find the values after the calculation is finished. They are not printed in the terminal and i don't find them in any file...

Thank you for your help!

Sascha September 12, 2012 08:12

I dunno if this thread is still interesting to anyone of you, but you should check the motorBike tutorial. Take a look at the controlDict and the forceCoeffsDict.
The results it gives will be found in your case directory. Dont wonder about having only one timestep there. Thats fine. This timestep holds a file with drag and lift coefficient and also the moment. Every timestep/iteration has its own line with the corresponding coefficients.
Just check the motorBike case. It should answer most of your questions.

Sascha September 12, 2012 08:26

The commercial use of OpenFoam is free. Many companies use it for their work. You may also modify the source code, but then you have to publish the changes.

elvis September 13, 2012 08:55


There are many CAD opportunities "BRL-CAD" was not mentioned yet ;-) .
=>To tackle snappyhexmesh I would recommend Helyx-OS as a Snappyhexmesh-GUI. With OF-command "surfaceFeatureExtract" you can create an "eMesh"-file which helps to achive better results while shm creates the OF-mesh (eMesh is supported in Helyx)

elvis September 13, 2012 10:13


is the commercial use of OpenFOAM free?
Yes it is free and you save a lot of money if you use it on large clusters (and save the "number of cpu´s licence fees " from other companies)

since I need to refresh my university studies. I would like to know if you can suggest me some good CFD books?
Take a look at "Computational Methods for Fluid Dynamics (Ferziger Peric)"

adampaya September 14, 2012 01:50

Hello everyone
I have some challenge in using the peric code
For example consider 2DGL, when I generate the gird for the geometry, what's the next step??? Should I use the Caffa.f or user.f ????
I read the read me file, but I don't understand.:mad:

Thanks for your help.

All times are GMT -4. The time now is 20:25.