# [OpenFOAM] Forces Calculation

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 8, 2013, 04:26 [OpenFOAM] Forces Calculation #1 Member   M Join Date: Jul 2012 Posts: 33 Rep Power: 13 Hello everyone, I am realizing since few days the aerodynamic study of a building, in a flow (wind) at 100 km/h. I realized the same study with CFX. I want to finally compare the two results. The problem is that finally, with approximate the same mesh, the same turbulence model and same parameters, I don't obtain the same field of pressure on the surface of the building. So, I want to calculate the total pressure force which is on the building surface. Does a function exist in OpenFOAM which can realize this kind of calculation ? A kind of "F=sum(CellAera*scalar(p))" I tried putting "forces" key word and parameters in control dict, but it seemed not working, i don't know how to use it well. . .. Thanks by advance, Please ask question if I am not clear. m_f

 March 8, 2013, 13:43 #2 Member   Pengchuan Wang Join Date: Nov 2012 Location: Michigan USA Posts: 58 Rep Power: 13 Hi m_f, I'm new to OpenFOAM as well, so I don't know whether this will helps you. But you can try this. I use force library to calculate torque. Just add the following command in the controlDict file. functions ( forces_fixedWall (patch name, in my case is fixedwall) { type forces; functionObjectLibs ("libforces.so"); outputControl timeStep; outputInterval 1; (write torque output, I write every time step) patches (fixedWall); (patch name) // pname p; // Uname U; rhoName rhoInf; log true; rhoInf 798; (798 is the density of the fluid, you need to change it) CofR (0 0 0); } ) Again, I'm not sure whether this works, you can try it. Pengchuan

 March 9, 2013, 00:01 #3 Member   M Join Date: Jul 2012 Posts: 33 Rep Power: 13 Hi, Thanks for your answer. I think I had already try this funtion, but I didn't use the same syntaxe...maybe that explain why it didn't work . Unfortunately, even if your function seems worked (I obtain some results during calculation), there is a big difference between the value given by OpenFOAM (with this function) and the value given CFX. CFX Forces (X-direction) is around 2.5e+09 N OpenFOAM Forces (sum pressure + viscous) is around 1.89e+013 N. Update : My mistake, it was 2.1e+07 N for CFX Forces (X-Direction), that's mean OpenFOAM Forces are 2 times bigger CFX Forces, I really don't understand . . . It is approximately the same mesh, the same parameters, so i can't explain this difference. Moreover, the two results are totally converged. So, is there others parameters to give to "forces function" of OpenFOAM, as Area or something else, which can give me betters results ? Thanks again for your last answer Last edited by m_f; March 11, 2013 at 08:24.

 March 12, 2013, 08:26 #4 Member   M Join Date: Jul 2012 Posts: 33 Rep Power: 13 Nobody has encounter this problem or can help me ?

 March 12, 2013, 10:01 #5 Senior Member   Olivier Join Date: Jun 2009 Location: France, grenoble Posts: 272 Rep Power: 17 hello, I don't have encounter this problem before, but something is suspicious: - You get 2.1e+07 N with CFX. - You get 1.89e+013 N with openfoam, so there is a 1e6 factor. This is a too nice number for me. My inclination would be a mistake in the force calculation, with a viscosity factor, or even a mesh not in m, .... regards, olivier

March 13, 2013, 03:18
#6
Member

M
Join Date: Jul 2012
Posts: 33
Rep Power: 13
Quote:
 Originally Posted by olivierG hello, [...]so there is a 1e6 factor. This is a too nice number for me. My inclination would be a mistake in the force calculation, with a viscosity factor, or even a mesh not in m, ....
I exactly thought the same thing, but after checking, I use exactly the same geometry file in the two cases...
But you make me in the doubt again, so I checked with another point of view.
blockMeshDict is in meter, right ?
I use CATIAV5R17 to export STL file, but CATIA works with mm. SnappyHexMesh need STL in meters by default ? I will checked with a 0.001 scale of my stl file.
I was pretty sure that was a stupid mistake....!

Edit : Problem solved ! Shame on me -_-, Thanks for your helped. . . I thought STL file was exported in meters by CATIA, not in mm. . . even if CATIA works in mm . . .

 January 13, 2015, 03:27 #7 Member   Emad Tandis Join Date: Sep 2010 Posts: 77 Rep Power: 15 hello I have a same problem with studying lift for NACA0012 airfoil at 4 degree angle of attact. Re=3e6 and C=1 m and span=0.1, then I put this function in controlDict: forceCoeffs { type forceCoeffs; functionObjectLibs ( "libforces.so" ); outputControl timeStep; outputInterval 50; patches ("walls"); pName p; UName U; rhoName rhoInf; log true; liftDir (-.0349 .9976 0); dragDir (.9976 .0349 0); CofR (0 0 0); pitchAxis (0 1 0); magUInf 30.00; rhoInf 1.00; lRef 1.00; Aref 0.1; } i used simplefoam to solve the case. and different sizes of mesh has been tested. and Cl is calculated 0.18. but I expect Cl~0.4 . what's the problem?? sk11, arashgmn and s.maleki like this. Last edited by EmadTandis; January 13, 2015 at 17:15.

 December 22, 2017, 10:33 forces code #8 Senior Member   A. Min Join Date: Mar 2015 Posts: 305 Rep Power: 12 Hi I want to calculate forces for viscoelastic fluid flow. According to what I found out, just I should change the "fT" , i.e. tangential force. in forces.C code we can see: -etaS*dev(twoSymm(fvc::grad(U))); for shear stress. I have three questions: 1- why did it use deviatoric form of twoSymm(fvc::grad(U)) tensor? As you know the shear stress tensor is calculated by: -etaS*twoSymm(fvc::grad(U)) why deviatoric?! 2- why did it use minus in formula? 3- if I want to add it polymer stress tensor, what should I do? is it enough to write: (+ or - ??)tau - etaS*dev(twoSymm(fvc::grad(U))); thanks

 April 10, 2018, 04:13 How can i get calculated force? #9 New Member   Park Kyurin Join Date: Apr 2018 Location: KOREA Posts: 3 Rep Power: 8 i wrote function to get force in ControlDict like below. functions { forces { type forces; functionObjectLibs ("libforces.so"); patches (wall); writeFields yes; writeContol timeStep; writeInterval 1; outputControl timeStep; outputInterval 1; rhoInf 999; rho rho; U U; p p; log yes; cofR (0 0 0); } } I got the force on the terminal window like below. forces output: forces(pressure,viscous,porous) = ((-10.0548, -26.3829, 80.0838),(-2.40928, 0.349221, -0.116824), (0,0,0)) moment(pressure,viscous,porous) = ((12.8587, 14.2552, 2.46935),(-0.0233112, 0.0278696, 0.442305), (0,0,0)) i want to get the force on wall. but they give me the force in 3 direction. can i calculate the force using this formula ? (fpx^2 + fpy^2 + fpz^2) ^0.5 + (fvx^2 + fvy^2 + fvz^2) ^0.5 (fpx - pressure force in x direction, fvx - viscous force in x direction) or how can i get summation of force? fpx + fvx means drag force? I need to check the force definition of openfoam. I would appreciate your reply.

April 10, 2018, 08:59
#10
Senior Member

A. Min
Join Date: Mar 2015
Posts: 305
Rep Power: 12
Quote:
 Originally Posted by kyurinPark i wrote function to get force in ControlDict like below. functions { forces { type forces; functionObjectLibs ("libforces.so"); patches (wall); writeFields yes; writeContol timeStep; writeInterval 1; outputControl timeStep; outputInterval 1; rhoInf 999; rho rho; U U; p p; log yes; cofR (0 0 0); } } I got the force on the terminal window like below. forces output: forces(pressure,viscous,porous) = ((-10.0548, -26.3829, 80.0838),(-2.40928, 0.349221, -0.116824), (0,0,0)) moment(pressure,viscous,porous) = ((12.8587, 14.2552, 2.46935),(-0.0233112, 0.0278696, 0.442305), (0,0,0)) i want to get the force on wall. but they give me the force in 3 direction. can i calculate the force using this formula ? (fpx^2 + fpy^2 + fpz^2) ^0.5 + (fvx^2 + fvy^2 + fvz^2) ^0.5 (fpx - pressure force in x direction, fvx - viscous force in x direction) or how can i get summation of force? fpx + fvx means drag force? I need to check the force definition of openfoam. I would appreciate your reply.

Hi Park

If you want to calculate the net force you should use the earned data by openfoam in a excel file:

Question: fpx + fvx means drag force?
if x is your flow direction, yes

Suggestion: If I were you, I would check the Cd values in postProcessing folder of your problem folder. Then you can calculate the total drag force with this formula:
Drag = 0.5*rho*U_inf^2*Cd*Aref

if you want to check the force definition of openfoam, you can see the forces.C code in postProcessing folder of src folder

Last edited by alimea; April 12, 2018 at 12:34.

April 12, 2018, 12:27
[OpenFOAM] Forces Calculation
#11
Senior Member

Charles
Join Date: Aug 2016
Posts: 148
Rep Power: 9
Quote:
 Originally Posted by EmadTandis hello I have a same problem with studying lift for NACA0012 airfoil at 4 degree angle of attact. Re=3e6 and C=1 m and span=0.1, then I put this function in controlDict: forceCoeffs { type forceCoeffs; functionObjectLibs ( "libforces.so" ); outputControl timeStep; outputInterval 50; patches ("walls"); pName p; UName U; rhoName rhoInf; log true; liftDir (-.0349 .9976 0); dragDir (.9976 .0349 0); CofR (0 0 0); pitchAxis (0 1 0); magUInf 30.00; rhoInf 1.00; lRef 1.00; Aref 0.1; } i used simplefoam to solve the case. and different sizes of mesh has been tested. and Cl is calculated 0.18. but I expect Cl~0.4 . what's the problem??
To get the correct CL, you need check all the parameters. It seems to me that the lift direction is forward inclined (i.e. angle of attack is -4 degrees instead of 4 degrees). I don't know your coordinate system, but it is worth to double check.

April 12, 2018, 12:33
Re: How can i get calculated force?
#12
Senior Member

Charles
Join Date: Aug 2016
Posts: 148
Rep Power: 9
Quote:
 Originally Posted by alimea Hi Park If you want to calculate the net force you should use the earned data by openfoam in a excel file: Question: fpx + fvx means drag force? if x is your flow direction, yes Suggestion: If I were you, I would check the Cd values in postProcessing folder of your problem folder. Then you can calculate the total drag force with this formula: Drag = 0.5*rho*U_inf^2*Cd if you want to check the force definition of openfoam, you can see the forces.C code in postProcessing folder of src folder
Hi Park,

Force is a vector...it has 3 component (Fx, Fy, Fz). In this case, you have two force, force due to pressure and force due to viscous. You would need vector summation to get the net force.

A. Min, I think your drag force formula missed reference area. It should be Drag = 0.5*rho*U_inf^2*C*Aref

April 12, 2018, 12:34
#13
Senior Member

A. Min
Join Date: Mar 2015
Posts: 305
Rep Power: 12
Quote:
 Originally Posted by Marpole Hi Park, Force is a vector...it has 3 component (Fx, Fy, Fz). In this case, you have two force, force due to pressure and force due to viscous. You would need vector summation to get the net force. A. Min, I think your drag force formula missed reference area. It should be Drag = 0.5*rho*U_inf^2*C*Aref
Yes
thank you Charles
I will edit it.

 April 12, 2018, 19:16 #14 New Member   Park Kyurin Join Date: Apr 2018 Location: KOREA Posts: 3 Rep Power: 8 Thank u so much, A.Min and Charles. i will do it!