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/)
-   -   Forces in V1.6 (https://www.cfd-online.com/Forums/openfoam-post-processing/67984-forces-v1-6-a.html)

terrybarnaby September 2, 2009 11:35

Forces in V1.6
 
Hi, I have updated from 1.5 to 1.6 (GIT source). I have modified some of my cases control files to get OpenFOAM 1.6 to work but I am having problems with forces in simpleFoam.
I get the error message:
--> FOAM Warning :
From function void forces::read(const dictionary& dict)
in file forces/forces.C at line 277
Could not find U, p or rho in database.
De-activating forces.
--> FOAM Warning :
From function void forces::read(const dictionary& dict)
in file forces/forces.C at line 277
Could not find U, p or rho in database.
De-activating forces.
My controlDict force configuration is:

functions
(
forces
{
type forces;
functionObjectLibs ("libforces.so");
outputControl outputTime;

// Patches to sample
patches (car_car);
// Name of fields
pName p;
Uname U;
// Dump to file
log true;
// Density
rhoInf 1.17;
// Centre of rotation
CofR (0 0 0);
}

forceCoeffs
{
type forceCoeffs;
functionObjectLibs ("libforces.so");
outputControl outputTime;

// Patches to sample
patches (car_car);
// Name of fields
pName p;
Uname U;
// Dump to file
log true;
// Density
rhoInf 1.17;
// Centre of rotation
CofR (0 0 0);

// Direction for lift
liftDir (0.0 1.0 0.0);
// Direction for drag
dragDir (1.0 0.0 0.0);

// Pitching axis
pitchAxis (0 0 0);

magUInf 13.0;

lRef 2.5;
Aref 0.296256;
}
);

Any one have any idea what is wrong ?

terrybarnaby September 2, 2009 12:33

Looking at the source code it looks like I need to add: "rhoName rhoInf;" to the "forces" and "forceCoeffs" entreis in controlDict or provide a "rho" initial conditions file in "0".
This appears to work ...

MadsR September 4, 2009 02:24

Nice find, it worked for me too.

/Mads

ronaldo September 19, 2009 05:26

could someone tell me the best way to simulate the Flow over a Cylinder?
Laminare, k-epsilon and k-omega!

openfoam_user October 14, 2009 09:09

Terry,

I am using MRFSimpleFoam - OpenFoam-1.6.x.

I get the following message error :

Starting time loop

--> FOAM Warning :
From function void forces::read(const dictionary& dict)
in file forces/forces.C at line 278
Could not find U, p or rho in database.
De-activating forces.

My controlDict is :

functions
(
forces
{
type forces;
functionObjectLibs ("libforces.so"); //Lib to load
patches (object1); // change to your patch name
pName p;
Uname U;
rhoName rho;
rhoInf 1.225; //Reference density for fluid
CofR (0 0 0); //Origin for moment calculations
outputControl timeStep;
outputInterval 1;
}
);

How do I modify my controlDict file ?

Regards,

Stephane

terrybarnaby October 14, 2009 09:22

Hi,

You need to add:

rhoName rhoInf;
rhoInf 1.17;

instead of:

rhoName rho;
rhoInf 1.225; //Reference density for fluid

I think...

Cheers


Terry

terrybarnaby October 14, 2009 09:24

Obviously rhoInf should be set how you need it :)

openfoam_user October 14, 2009 09:39

Thanks Terry,

Now it works fine !

One more question.
And if I want to have the forces results like below (tail -f log) in the log file ?

Courant Number mean: 0.000625962 max: 0.0181186
DILUPBiCG: Solving for Ux, Initial residual = 8.58271e-05, Final residual = 5.68736e-12, No Iterations 1
DILUPBiCG: Solving for Uy, Initial residual = 0.000135717, Final residual = 1.58931e-11, No Iterations 1
DICPCG: Solving for p, Initial residual = 0.000308555, Final residual = 2.98446e-06, No Iterations 6
DICPCG: Solving for p, Initial residual = 5.6599e-06, Final residual = 9.87842e-07, No Iterations 193
DICPCG: Solving for p, Initial residual = 1.97131e-06, Final residual = 8.93472e-07, No Iterations 1
DICPCG: Solving for p, Initial residual = 9.0792e-07, Final residual = 9.0792e-07, No Iterations 0
time step continuity errors : sum local = 9.67148e-15, global = -1.15687e-16, cumulative = -1.07021e-10
DICPCG: Solving for p, Initial residual = 9.19959e-07, Final residual = 9.19959e-07, No Iterations 0
DICPCG: Solving for p, Initial residual = 9.19959e-07, Final residual = 9.19959e-07, No Iterations 0
DICPCG: Solving for p, Initial residual = 9.19959e-07, Final residual = 9.19959e-07, No Iterations 0
DICPCG: Solving for p, Initial residual = 9.19959e-07, Final residual = 9.19959e-07, No Iterations 0
time step continuity errors : sum local = 9.79972e-15, global = -1.14472e-16, cumulative = -1.07021e-10
ExecutionTime = 25809.3 s ClockTime = 77462 s
forces output:
forces(pressure, viscous)((3.36459 -0.00234243 9.49148e-20) (0.365777 -2.56403e-05 -1.76832e-22))
moment(pressure, viscous)((3.41853e-19 -8.54044e-18 -0.00215479) (-8.87561e-22 1.48373e-20
0.0157578))
forceCoeffs output:
Cd = 152.26
Cl = -0.0966561
Cm = -1.91544e-17
Time = 2.417



Stephane.

terrybarnaby October 14, 2009 09:44

Sorry, I am only a novice at this so I don't know how to do that.

You could try adding:
log true;

I'm not sure what that does ...

griztown November 3, 2009 16:24

Hi,

Is there not a website or tutorial anywhere that gives some instructions for using the forces function? Does it really take digging through the source code? Any links or tips would be much appreciated!

Thanks

AirS December 2, 2009 07:54

Hi all,

I want to investigate the forces acting on a cylinder so I use the entry "forces" in the controlDict,
It works well but in the file .dat I've got something like that:

forces(pressure, viscous)((3.36459 -0.00234243 9.49148e-20) (0.365777 -2.56403e-05 -1.76832e-22))
moment(pressure, viscous)((3.41853e-19 -8.54044e-18 -0.00215479) (-8.87561e-22 1.48373e-20))

What does (pressure, viscous) mean ? I want to compute all the forces that is to say Fx,Fy,Fz.
I can't see them anywhere in the data file...
Is there something I'm missing?
Thanks.


terrybarnaby December 2, 2009 08:01

As far as I know:
Pressure force is the force on the object due directly to pressure differences.
Viscous force is the force due to the "friction" of the fluid passing over the objects surface.

To get the total force acting on the object you need to add the pressure components to the viscous components.

g.redondo December 15, 2009 10:45

Multi-phase
 
Hi all,

I was trying to include the density in the forces.C file and I found that there are already some lines regarding to it. Therefore I wonder if multi-phase is already supported in OF1.6.

If so, how should the controlDict entry be. If it doesn't support it, how should it be included? The most important line would be the following. I think it should be:

vectorField vf = (Sfb[patchi] & devRhoReffb[patchi])*rho.boundaryField()[patchi];

and it is:

vectorField vf = Sfb[patchi] & devRhoReffb[patchi]

has anyone fixed this?

Gonzalo

jploz December 16, 2009 04:03

Hi Gonzalo,

no, the forces object supplied with OF 1.6 does not support multiphase flow. It uses the prescribed density "rhoInf" when calculating the viscous forces (as I already wrote here http://www.cfd-online.com/Forums/ope...ip-flow-2.html) which is obviously not correct in the case of compressible flow and flow involving more than a single incompressible phase. If you would use a constant density in such case your resulting viscous forces would differ a lot.

In order to fix this, you need to read the current density field and use that instead of the defined "rhoInf".

Good luck.
Jean-Peer

83_Ale_83 December 21, 2009 05:53

Quote:

Originally Posted by griztown (Post 235002)
Hi,

Is there not a website or tutorial anywhere that gives some instructions for using the forces function? Does it really take digging through the source code? Any links or tips would be much appreciated!

Thanks

Quote,
anyone can help me? I'am trying to calculate the drag and lift on a cylinder with simplefoam..any advise?

Thank you

santos December 21, 2009 06:55

Hi,

Put something like this in your system/controlDict, changing accordingly to your situation:

Code:

functions
{
forces
{
type forces;
functionObjectLibs ("libforces.so"); //Lib to load
patches (sphere_region0); // change to your patch name
rhoName rhoInf;
rhoInf 1000; //Reference density for fluid
CofR (2 0 0); //Origin for moment calculations
        outputControl  timeStep;
        outputInterval  1;
}
forceCoeffs
{
// rhoInf - reference density
// CofR - Centre of rotation
// dragDir - Direction of drag coefficient
// liftDir - Direction of lift coefficient
// pitchAxis - Pitching moment axis
// magUinf - free stream velocity magnitude
// lRef - reference length
// Aref - reference area
type forceCoeffs;
functionObjectLibs ("libforces.so");
patches (sphere_region0);
rhoName rhoInf;
rhoInf 1000;
CofR (2 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 1);
magUInf 1e-7;
lRef 0.06; // sphere diameter
Aref 0.0014137; //1/2 * projected area = pi*rē/2

        outputControl  timeStep;
        outputInterval  1;
}

}

Regards,
Jose Santos

83_Ale_83 December 21, 2009 07:50

Impressive;)

I have put in my controlDict file this code:

Quote:

type forces;
functionObjectLibs ("libforces.so"); //Lib to load
patches (cilindro); // change to your patch name
pName p;
Uname U;
rhoName rhoInf;
rhoInf 1.17;
CofR (0 0 0); //Origin for moment calculations
outputControl timeStep;
outputInterval 1;
"My" code calculates the forces, your code calculates the coefficient right?
With regards

santos December 21, 2009 10:04

"My" code calculates both the forces and their coefficients ;-)

83_Ale_83 December 21, 2009 10:27

Quote:

Originally Posted by santos (Post 240660)
"My" code calculates both the forces and their coefficients ;-)

Thank you, I tried and it works very well ;)

83_Ale_83 February 23, 2010 03:17

Hello to everybody,
I'm trying to remove the brackets and the header from forces.dat output file, any advise please?

Thank you in advance

ngj February 23, 2010 03:41

Hi Alessandro

You could try something like this in the command line:

grep -v "<word in header>" forces.dat | tr -d '(' | tr -d ')' > forces.dat.modified

I do not have a forces.dat file available, hence just replace <word in header> with a word from the header. Then it should work without any problems.

Best regards,

Niels

83_Ale_83 February 23, 2010 04:05

Quote:

Originally Posted by ngj (Post 247005)
Hi Alessandro

You could try something like this in the command line:

grep -v "<word in header>" forces.dat | tr -d '(' | tr -d ')' > forces.dat.modified

I do not have a forces.dat file available, hence just replace <word in header> with a word from the header. Then it should work without any problems.

Best regards,

Niels

Thank you very much, it does exactly what I was looking for:D

AirS February 23, 2010 06:22

You should try this:

sed 's/(/ /g' forces.dat > forcesi
sed 's/)/ /g' forcesi > forces

where forces is the same file as forces.dat without the brackets.
Hope it helps!

jploz February 23, 2010 10:24

Hi,

you can use any text postprocessing tool you like (e.g. sed, awk, a perl script) and modify the file (described above).

If you want to remove it directly from the output you will have to create your own version of the forces function object and remove the according lines of source code and recompile it.

HTH.

83_Ale_83 February 23, 2010 10:50

Thank a lot for your advises, I take in consideration all of them:o

rubenparedes February 25, 2010 19:48

Hi,

You can do it in a different way, please check [1]. They recommend to add some lines in the foamLog script.

Ruben

[1] http://www.cfd-online.com/Forums/ope...rces-of15.html

83_Ale_83 February 26, 2010 02:59

Hi Ruben,

thank you for the advice but I have changed che controlDict in order to obtain the forces values...I don't know how to obtain forces and coeffs from a log file

Quote:

functions
{
forces
{
type forces;
functionObjectLibs ("libforces.so"); //Lib to load
patches (ala); // change to your patch name
rhoName rhoInf;
rhoInf 1.184; //Reference density for fluid
CofR (1 0 0); //Origin for moment calculations
outputControl timeStep;
outputInterval 1;
}
forceCoeffs
{
// rhoInf - reference density
// CofR - Centre of rotation
// dragDir - Direction of drag coefficient
// liftDir - Direction of lift coefficient
// pitchAxis - Pitching moment axis
// magUinf - free stream velocity magnitude
// lRef - reference length
// Aref - reference area
type forceCoeffs;
functionObjectLibs ("libforces.so");
patches (ala);
rhoName rhoInf;
rhoInf 1.184;
CofR (1 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 1);
magUInf 25;
lRef 1; // sphere diameter
Aref 0.1; //1/2 * projected area = pi*rē/2

outputControl timeStep;
outputInterval 1;
}
}

rubenparedes February 26, 2010 06:25

Hi Ale,

I use 1.5 version, but I assume that 1.6 version generates a forces directory where the forces.dat file is saved. Check reply # 19 in [1]

good luck,

R

SD@TUB February 28, 2010 18:53

Quote:

..., but I assume that 1.6 version generates a forces directory where the forces.dat file is saved.
That's correct.
I'm facing some problems of forces output for several patches. Entering all patch names within
Code:

patches (patch1 patch2 patch3 ...);
i get summarized forces and moment for the given patches. But i want to distinguish the forces/moments of each patch. When i repeat
Code:

forces
{
...
}

for every patch, the data are seperated but mixed together within ./forces/<firstTimeStep>/forces.dat! I prefer a solution of creating directories for everey patch, like ./forces/patch1/forces.dat, ./forces/patch2/forces.dat and so on. Any advise of handling several patches in functions -> forces is much appreciated...


/Stefan

rubenparedes March 2, 2010 00:06

Hi Stefan,

I am new to OpenFoam and Cpp, so maybe I will say something stupid. Also, I have never worked with multiple patches, what do you mean when you say "for every patch, the data are separated but mixed together within ./forces/<firstTimeStep>/forces.dat"?

I was reading the force.C file, and it looks like in the makeFile() function the force directory is set as:
forcesDir = obr_.time().path()/name_/obr_.time().timeName();

So, I think that changing the "/obr_.time().timeName()" part with a kind of "/patchSet_()[# ID of patch in list?]" could work to get a directory <#IDpatch>/forces.dat.

That makes sense?,

R.

SD@TUB March 3, 2010 04:31

Hello Ruben,

that could be a solution (i didn't try it).
What i did to fix it, is some way easier. Ich changed
Code:

forces
{
...
}

in
Code:

patchname
{
...
}

within functions{...} and i get different directories for the included patches!

/Stefan

83_Ale_83 March 17, 2010 09:29

Hello,
I need to look inside the code of libforces...How I can do it? I would like to know in which way openfoam compute the forces...

SD@TUB March 17, 2010 17:00

In case of 64-bit setup, libforces.so is located at
HTML Code:

/usr/local/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libforces.so
In Doxygen the dependencies of forces treatment are listed, see here:
http://foam.sourceforge.net/doc/Doxy...1_1forces.html

Forces are integrated over given walls with patchIntegrate[patchI]. Viscous forces depends on shear stress, pressure forces are related to the pressure field on the wall.

alexisespinosa March 22, 2010 21:21

Calculating forces from results without running the case again
 
Following the indications in this thread, I was able to set the force calculation for a flow past a cylinder.

But I have done a lot of runs in the past days without these settings and i want to calculate the forces from the result files that I already have, because running again the cases will be very time consuming. Obvioulsly, it is possible. I just need to read the U and p files for every saved time and use the force functions to calculate forces.

But how can I do that???

Thanks a lot.
Alexis

rubenparedes March 22, 2010 21:44

Hi Alexi,

I think that you can use the "execFlowFunctionObjects" utility, but first you need to include in the controlDict file the forceObject as described above.

R.

alexisespinosa March 23, 2010 01:27

Thanks Ruben,

The execFlowFunctionObjects is working, BUT it creates a result file for every saved time step! That is a problem, but the biggest problem is that it overwrites it each time step. So, at the end I get just one file with the forces for the latest time step that i have saved.

Do you know how to avoid overwriting?? It would be wonderful if execFlowFunctionObjects could work with all the saved timesteps just as if they were being generated in runtime. In that way it would output just one file at the end but with one line per processed time, instead of overwriting.

Thanks,
Alexis

rubenparedes March 23, 2010 10:22

Hi Alexi,

I am not sure about it, but it sounds to me like you are using:
outputControl timeStep;
outputInterval 1;

Maybe you can try using outputTime instead.

Good luck,

R.

alexisespinosa March 23, 2010 19:05

When I use
outputControl outputTime;
Then the utility processes every time directory I have with saved results, but it does not create any file. Nothing!!
When I use
outputControl timeStep;
outputInterval 1;
Then again, execFlowFunctionObjects process every time directory and creates a forces.dat file for every time, but it always overwrite the old one, so it keeps overwriting files and at the end i finish with just one file. The problem is that in every file there is only one line with the calculated forces for that specific time. So, at the end I finish with just the calculated forces for the last time.

Thank you very much.

I also started a thread in OpenFoam_bugs about the execFlowFunctionObjects, I hope that we can also get some hints over there.

Thanks again,

Alexis

sandy March 28, 2010 08:32

Quote:

Originally Posted by ronaldo (Post 229903)
could someone tell me the best way to simulate the Flow over a Cylinder?
Laminare, k-epsilon and k-omega!

k-omegaSST

83_Ale_83 March 28, 2010 09:24

We are a little bit off topic, but why you think k-omega SST?


All times are GMT -4. The time now is 12:04.