Trying to obtain the surface forces

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

Post Reply
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Trying to obtain the surface forces

Post by NewJoker »

Hi,

I'm trying to obtain the output of forces (normal and tangential) for the whole surface of the object around which the flow occurs. I prepared the analysis in CfdOF, pressed Analysis control --> Case setup --> Write and added this to functions in case/system/controlDict file:

Code: Select all

    forces
    {
        type            forces;
        libs            ("libforces.so");
        patches
        (
            wall_001
        );
		CofR            (0 0 0);
		
		rho            rhoInf;

		log            true;

		rhoInf            1;

    }
Then I saved the file and pressed Analysis control --> Solver --> Run. The analysis finished successfully and I can open the results in ParaView but there are no variables associated with forces and I've noticed a long output with repeating errors in the Report view:

Code: Select all

File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\CfdOF\.\CfdOF\CfdConsoleProcess.py", line 98, in readStdout
new_text = self.stdoutHook(text)
File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\CfdOF\.\CfdOF\Solve\TaskPanelCfdSolverControl.py", line 290, in gotOutputLines
self.solver_runner.process_output(lines)
File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\CfdOF\.\CfdOF\Solve\CfdRunnableFoam.py", line 263, in process_output
f = self.forces[self.in_forces_section]
KeyError: 'forces'
Do you know what can be wrong here ?

I attached the .FCStd file below.

Sphere test.FCStd
(21.29 KiB) Downloaded 33 times

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: Polish/Poland (pl_PL)
Last edited by NewJoker on Thu Jun 30, 2022 2:59 pm, edited 1 time in total.
thschrader
Veteran
Posts: 3129
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Trying to obtaining the surface forces

Post by thschrader »

There are 2 methods to get the fluid-forces acting on the body.

Method 1:
Use the report function tool in cfdof.
You must precalculate the reference-pressure. In your case 23 Pa for air with density 1,2 kg/m^3 and v=6 m/s.
Report gives back 0,021-0,022 Newton in x-direction.

Method 2:
Open the results in paraview and use a sequence of filters/Calculator to get the forces as shown here:
https://www.youtube.com/watch?v=J944HOj_4b0
paraview calculates 0,021 N (dragX)

check gives c-drag=0,74 for the sphere.

Calculating the shear force in the fluid is a little bit tricky, you must calculate the velocity-gradient:
https://www.youtube.com/watch?v=nRXYWNEulio

Hope that helps.
method1.JPG
method1.JPG (78.47 KiB) Viewed 1219 times
method2.JPG
method2.JPG (136.37 KiB) Viewed 1219 times
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Trying to obtaining the surface forces

Post by NewJoker »

thschrader wrote: Thu Jun 30, 2022 2:49 pm There are 2 methods to get the fluid-forces acting on the body.
Thank you for the reply. I've already tried the first method but it only gives the total force for the whole sphere. The second approach is doable but I'm still looking for something different. The thing is that I need a distribution of forces (normal and tangential) on the surface of the object in the fluid. That's because I want to import these forces to solid mechanics FEA software in the next step. The force function object in OpenFOAM should give me the kind of data that I'm looking for: https://www.openfoam.com/documentation/ ... orces.html

But I haven't figured out yet how to make it work. Maybe I have to include some additional libraries?
thschrader
Veteran
Posts: 3129
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Trying to obtaining the surface forces

Post by thschrader »

NewJoker wrote: Thu Jun 30, 2022 3:05 pm ...
That's because I want to import these forces to solid mechanics FEA software in the next step.
...
This is a tough approach. From openfoam you have "only" the p-field, distributed over 4 processors.
Even when you get the x,y,z-forces of each cell, you must handover it to the other FEA-program.
Which uses a different mesh...

There where discussions about this in the forum, cant find the post.

Maybe elmer is a way for FSI.
Or this:
https://precice.org/index.html

However, good luck. :)
Thomas
User avatar
NewJoker
Veteran
Posts: 3017
Joined: Sun Oct 11, 2020 7:49 pm

Re: Trying to obtaining the surface forces

Post by NewJoker »

thschrader wrote: Thu Jun 30, 2022 3:58 pm This is a tough approach. From openfoam you have "only" the p-field, distributed over 4 processors.
Even when you get the x,y,z-forces of each cell, you must handover it to the other FEA-program.
Which uses a different mesh...
Right, it seems to be way harder than I initially thought. Apparently, the force function object that I'm trying to use also outputs only total forces in the .dat file. Maybe the approach shown here (apart from integration to get totals) could help with normal forces: https://www.youtube.com/watch?v=J944HOj_4b0

But it would be tricky with shear ones.

Mapping to FEA mesh is not a problem for now. It will be handled separately. I just need the data in the form of position on the surface and corresponding force components.
Post Reply