CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How to plot drag and lift coeffs. (https://www.cfd-online.com/Forums/openfoam-post-processing/159336-how-plot-drag-lift-coeffs.html)

m5m5kh September 13, 2015 14:51

How to plot drag and lift coeffs.
 
1 Attachment(s)
Hi
I used icoFoam to simulate flow around a cylinder for Re=100. (U=1 D=1 rho=1 and nu=.01)
I add some lines to my control dict to calculate the drag and lift coeffs.
----------------------------------------------------------------------
functions
{
forces
{

type forceCoeffs;
functionObjectLibs ( "libforces.so" );
outputControl timeStep;
outputInterval 1;
patches
(
wall
);
pName p;
UName U;
rhoName rhoInf;
log true;
rhoInf 1;
CofR ( 0 0 0 );
liftDir (0 1 0);
dragDir ( 1 0 0 );
pitchAxis ( 0 0 0 );
magUInf 1;
lRef 1;
Aref 1;
}
}
-----------------------------------------------------
finally I had a forceCoeffs.dat file in postProcessing folder.
My main question is how to plot cd and cl data (16000 data) to have something like the attached picture.

davibarreira September 29, 2015 20:29

There is an OpenFOAM function which you can use called 'foamMonitor', you should try it out. I usually use it to check if the results are going the way I expect them to be. After that I use python to properly generate my graphs.

davibarreira October 7, 2015 14:25

I saw that you sent me a private message, but i will answer it here so other people can see it too.

So as you pointed out, you've got your forceCoeffs.dat
To use the foamMonitor, just go in the terminal and write:

Code:

foamMonitor ./postProcessing/0/forceCoeffs.dat
This code may vary depending on the location of your forceCoeffs file. One of the problems that you might have is that the y axis range might be to wide, so you cant see the results properly. For that, you might try:

Code:

foamMonitor -yrange [0:1.5] ./postProcessing/0/forceCoeffs.dat
Here you can find out more about foamMonitor:
https://github.com/OpenFOAM/OpenFOAM...ed0738f5b4a1c1

pratyush_6174 February 17, 2022 07:38

Facing error
 
while running the above code i am getting error.

fedenr February 17, 2022 09:33

You may need to put the limits in quotation marks



Code:

foamMonitor -g -y "[0:1.5]" ./postProcessing/0/forceCoeffs.dat

pratyush_6174 February 17, 2022 09:44

I am getting error while running the code in the control dict it is showing rho is not defined and many errors

fedenr February 21, 2022 04:21

Could you post your controlDict and the error?

pratyush_6174 February 24, 2022 02:50

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application icoFoam;

startFrom startTime;

startTime 0;

stopAt endTime;

endTime 1.0;

deltaT 0.01;

writeControl timeStep;

writeInterval 20;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable true;
functions
{
forces
{

type forceCoeffs;
functionObjectLibs ( "libforces.so" );
outputControl timeStep;
outputInterval 1;
patches
(
wall
);
pName p;
UName U;
rhoName rhoInf;
log true;
rhoInf 1;
CofR ( 0 0 0 );
liftDir (0 1 0);
dragDir ( 1 0 0 );
pitchAxis ( 0 0 0 );
magUInf 1;
lRef 1;
Aref 1;
}
}

// ************************************************** *********************** //

Error:-
--> FOAM FATAL ERROR: (openfoam-2112)
Could not find rho:rho

From void Foam::functionObjects::forces::initialise()
in file forces/forces.C at line 229.

FOAM exiting

fedenr February 24, 2022 05:00

I'm using version 2012 and not 2112, but i guess the configuration should be the same.


Instead of

Code:

rhoName          rhoInf;
You should have

Code:

rho          rhoInf;

That's why the error says


Code:

Could not find rho:rho

ghastbug March 28, 2022 04:12

What gnuplot version do I need to install to use foamMonitor?
Btw, if gnuplot does not work for you for whetever reason, I have an octave code I made for plotting aero coefficients in openfoam. It is more complicated than using gnuplot though

surajk.garad101 April 26, 2022 00:37

Hi,



I have tried both, but it didn't work for me. Also I have gone through all existing threads here. I am using openfoam 2112.


All times are GMT -4. The time now is 09:28.