CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Forces in OF15 (https://www.cfd-online.com/Forums/openfoam-solving/57829-forces-of15.html)

richard July 20, 2008 23:51

Hi all, I'm confused - the
 
Hi all,

I'm confused - the 1.5 release notes mention forces and forceCoeffs utilities, but they're not recognized as commands and I can't find anything in the users or programmers guides..?

Cheers,
Richard

richard July 21, 2008 04:15

I've tried added the following
 
I've tried added the following to my controlDict file (I haven't used functionObjects much before so I just changed the oodles example to suit - it could be wrong)...

functionObjects
(
forces
{
type forces;
functionObjectLibs ("libforces.so");
patches (airfoil);
factor 1.0;
}
)

but nothing new happens.

Also tried execFlowFunctionObjects after running the case and it spat out garbage about the memory map??

Is there any info on how to use forces and forceCoeffs..?

podallaire July 21, 2008 08:33

Good morning, I was able to
 
Good morning,

I was able to use the force object using this in my controlDict :

forces
{
type forces;
functionObjectLibs ("libforces.so"); //Lib to load -> dylib on Mac and so on Linux
patches (Bridge); //Name of patche to integrate forces
rhoInf 1.0; //Reference density for fluid - can be changed later ...
CofR (2.1267 0 0); //Origin for moment calculations
}

A "forces" directory is created and results for each time step are written in a .dat file.

I compared the results with the tool available in 1.4.1-dev and everything looks good. The only thing is that I don't know (without modifications in the source code) is how to extract each force component with foamLog or the new tool foamCalc in order to make 2d plots?

Any idea ?

Regards,

PO

ngj July 21, 2008 09:17

Hi Pierre So you say that i
 
Hi Pierre

So you say that in each and every time directory a file called 'forces.dat' is placed?

Could you please post one such forces.dat file, and I might be able to help you on making something which you can put into foamLog (still using 1.4.1, thus cannot access the functionObject).

Best regards,

Niels

ngj July 21, 2008 10:01

Hi PO Okay, just a little b
 
Hi PO

Okay, just a little bit of clarification.

1: So assume you have two patches (ora ny finite number), you would like to have the force/moment data written to two different (or any finite number of) files? (Please, because that would make everything significantly easier.)

2: You would like the files to be placed where?

3: I have made some small preliminary stuff, but will not make it more generic before we have agreed on some overall features. The preliminary output looks like:

#Time FpX FpY FpZ FvX FvY FvZ MpX MpY MpZ MvX MvY MvZ
1 41.9563 38.5186 1.23717e-06 -0.126958 -0.0442683 -0.00278829 -0.13884 0.0776653 -2.13127 -0.000449653 0.00121981 -0.000584387
2 41.9562 38.5193 1.23748e-06 -0.126959 -0.044268 -0.00278827 -0.139218 0.07758 -2.13122 -0.000449613 0.00122021 -0.000584434
3 41.9559 38.5201 1.23745e-06 -0.126961 -0.0442673 -0.00278824 -0.139608 0.0775009 -2.13116 -0.00044978 0.00122059 -0.000584453
4 41.9555 38.5209 1.23734e-06 -0.126962 -0.0442663 -0.00278812 -0.14007 0.0774062 -2.1311 -0.000450026 0.0012211 -0.000584461
5 41.9551 38.5221 1.23731e-06 -0.126964 -0.0442651 -0.00278792 -0.140901 0.0773055 -2.13104 -0.000450371 0.0012217 -0.000584472
6 41.955 38.5237 1.23846e-06 -0.126964 -0.044264 -0.0027877 -0.142047 0.0771426 -2.13097 -0.000450925 0.0012224 -0.000584534
7 41.955 38.5248 1.23847e-06 -0.126965 -0.0442625 -0.00278749 -0.142744 0.0771074 -2.13094 -0.000451635 0.00122299 -0.000584546

Which is simply done using the command:

echo "#Time FpX FpY FpZ FvX FvY FvZ MpX MpY MpZ MvX MvY MvZ" > forceData;awk '/[0-9]/ {print}' <testforces>> forceData

Where the data you delivered is placed in testForces.

Niels

podallaire July 21, 2008 10:10

Hi Niels, 1) Yes, different
 
Hi Niels,

1) Yes, different files are fine

2) I would say in "logs" directory if possible (created by foamLog)

3) That is exactly what I need - I will try. Is there a way to introduce this command in foamLog.db ? If not, I will just copy it in my run script.

Thanks !

PO

ngj July 21, 2008 10:18

Hi PO I can see that the po
 
Hi PO

I can see that the poster has truncated my post or at least removed some of the internal part of the command.

I'll try to wrap thing up and put it in foamLog, but so far, please use the following attached file:

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif extractForces

/Niels

/ Niels

podallaire July 21, 2008 10:23

Niels, thanks a lot, really
 
Niels,

thanks a lot, really appreciated !

PO

ngj July 21, 2008 12:01

Hi PO No problem, I like a
 
Hi PO

No problem, I like a small shell-scripting brush-up from time to timehttp://www.cfd-online.com/OpenFOAM_D...part/happy.gif

I have made this small script, which I believe should work as 'ordered' if you add it to the very bottom of the foamLog script. I have commented it quite extensively, hope that can enlighten you.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif addToFoamLog

There is a small detail, namely in line 2. My experience from Fedora and Mac tells me that 'find' works a little bit different with respect to the -maxdepth command, thus if you run into problems with that just 'man find'. I am on a Fedora machine right now, thus cannot verify my suspicion.

Have fun,

Niels

podallaire July 21, 2008 12:44

Nice, thanks again ! I will
 
Nice, thanks again !

I will verify the maxdepth command but it should be fine.

Best regards,

PO

richard July 21, 2008 19:51

Thanks for you help fellas! Fo
 
Thanks for you help fellas! For others trying to get it to work, put Pierre's forces object (post 3) in

functions
(
//pierre's code
);

at the end of the controlDict file.

richard July 21, 2008 20:08

Also, if you're adding Neils c
 
Also, if you're adding Neils code (cheers Neils, top work!) to foamLog change the $ROOT/$CASE to $CASEDIR since the . . has been left out of the arguments in 1.5

podallaire July 21, 2008 20:47

Hi ! Yes,$ROOT and $CASE ar
 
Hi !

Yes,$ROOT and $CASE are not used in 1.5 but I don't think that $CASEDIR is an argument with FoamLog - I "tweaked" Neils's code
to use the current directory instead.

Thanks !

PO

richard July 21, 2008 23:53

As far as I can tell this is w
 
As far as I can tell this is what you need for the forceCoeffs version... the variables are reasonably self explanatory

forceCoeffs
{
type forceCoeffs;
functionObjectLibs ("libforces.so");
patches (airfoil);
rhoInf 1.0;
CofR (0.25 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0.25 0 0);
magUInf 10.0;
lRef 1.0;
Aref 1.0;
}

foamLog can be modified as above, changing the forces reference to forceCoeffs where appropriate.

ngj July 22, 2008 04:19

Hi Well, here you go. Can s
 
Hi

Well, here you go. Can someone please make foamLog v. OF1.5 available to me.

Thanks,

Niels

podallaire July 22, 2008 07:17

How do we attach files ???
 
How do we attach files ???

Thanks

PO

jaswi July 22, 2008 07:29

Hi Niels Please excuse me f
 
Hi Niels

Please excuse me for interrupting the thread but I tried to send you an email and it returned me an negative Delivery Status Notification.

Could you please mail me your email address.
I have some doubts and need you help

Thanks alot
Jaswi

ngj July 22, 2008 07:47

Hi PO Look in the Documenta
 
Hi PO

Look in the Documentation->Formatting section to the left.

- Niels

BTW. Richard have mailed it to me directly.

podallaire July 22, 2008 08:02

Here it is ... http://www
 
Here it is ...

http://www.cfd-online.com/OpenFOAM_D...s/mime_txt.gif addToFoamLogV2.txt

It assumes that foamLog is executed from the case directory where the folder "forces" can be found and where the output folder "logs" will be created.

Thanks

PO

sjs July 22, 2008 17:42

Thank you guys for all the pos
 
Thank you guys for all the posts --- I was just trying to sort through this on my own. unfortunately, copying the code for the controlDict doesn't seem to work for me (I used snappyHexMesh and then ran icoFoam). I don't see any forces directory. Where is this directory supposed to be created?

Also, what are the units of the output? Are they Newtons for force and N*m for moment and dimensionless for the output of force coeff? (just want to make sure it isn't somehow N/m^2)

Thank you.
Sylvia

richard July 22, 2008 20:10

Gday Sylvia, Just check all
 
Gday Sylvia,

Just check all the semi-colons, spaces, brackets (normal and curly) and spelling are correct. For a while I had the same problem with the forces file not appearing, there wasn't any error output.

I haven't had a chance to check the units yet, but at first glance it looks like N, Nm and dimensionless.

Cheers!
Richard

sjs July 22, 2008 20:35

Thanks, Richard. I had copied
 
Thanks, Richard. I had copied syntax from an earlier post in the thread and that was wrong --- it didn't give any error messages, so it took me awhile to realize it was wrong. Everything's great now.

cheers,
Sylvia

gregorv July 23, 2008 03:54

I had a similar problem. Make
 
I had a similar problem. Make sure you have the entry "functions" not "functionObjects" in the controlDict file. Richard mentions this in his post, but it takes a keen eye to spot the difference, it took me a while to see the issue.

Cheers,

-Gregor

ivanwhlau August 5, 2008 02:03

Hi, I am trying to validate t
 
Hi,
I am trying to validate the force coefficient using turbFoam (2D incompressible wind flow around a square cylinder)
What is wrong with my force coefficient:
I got very large magitude (Cd = 1.27e+4), which I expect Cd = 1.6
I noted that I need to multiply this by density (1.225kg/m^3), but still.....

Here is my paramenter
forceCoeffs
{
type forceCoeffs;
functionObjectLibs ("libforces.so");
patches (building);
rhoInf 1.0;
CofR (0 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 0);
magUInf 1;
lRef 1.0;
Aref 1.0;
}
Btw, where can I find the explanation these function parameters?
Regards,
Ivan

richard August 5, 2008 02:39

Hi Ivan, Your forceCoeffs d
 
Hi Ivan,

Your forceCoeffs description looks fine.

I can't find an explanation for the function parameters either - most seem logically named, but what has me puzzled is the pitchAxis and CofR parameters..? Are they meant to be different?

The nature of the transient rans technique makes it pretty poor at resolving forces - since it is trying to average flow over a small time. But they certainly shouldn't be that bad. It's more likely to be poor convergence by the sounds of it (use foamLog and plot initial residuals over time and make sure the max Courant number stays down around 0.2 or 0.3)

eugene August 5, 2008 05:25

Err, you have specified the re
 
Err, you have specified the reference area (Aref) as 1 m2 and the reference velocity (magUInf) as 1 m/s. So the result you are looking at is more like the force in Newtons times (2*rho).

Definition of terms:
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

ivanwhlau August 5, 2008 08:48

Hi, Eugene and Richard, Thank
 
Hi, Eugene and Richard,
Thanks for your comment
Richard, I tried to find information about the difference between pitchAxis and CofR. I only know pitch is related to airplane.
By the way, do you know if there is any easy way to plot/calculate pressure coefficient?
Cheers,
Ivan

olwi August 5, 2008 09:14

Hi, I would assume CofR to
 
Hi,

I would assume CofR to be a point, and pitchAxis to be a vector (presumably in the transverse direction, relative to the motion/flow). But Eugene's should be able to tell you what it does...

/Ola

mgz1985 August 6, 2008 06:50

hi all, where is this new d
 
hi all,

where is this new directory created after copying the patch above to controlDict. I copied at the bottom of controlDict for my case and ran icoFoam

but i do not see any new directory anywhere. can sum1 tell exactly where is this directory.

thanx all

ivanwhlau August 6, 2008 13:03

Hi Mayank, If you do it corre
 
Hi Mayank,
If you do it correctly, you should see the "forces" and/or "forceCoeffs" folder insides case directory. [Version 1.5 only]
Ivan

mgz1985 August 6, 2008 14:07

hi ivan, I can tell you wha
 
hi ivan,

I can tell you what I did

I copied the fie above posted by you.it was placed at the bottom of the controlDict file. I made the appropriate changes i.e. renamed the patch and made the change in functionObjectLibs ("libforces.so") to functionLibs ("libforces.so").

This is what I did. I did check for the semi-colons and all. There was no syntax error generated by the machine.

If it is ok, I can post my controlDict file here for your review tomorrow as I am not in my office right now.

Thanx for replying

ivanwhlau August 6, 2008 20:11

Hi Mayank, I think I know you
 
Hi Mayank,
I think I know your problem....
Try the following but change your parameters:

functions // this one!
(
forces
{
type forces;
functionObjectLibs ("libforces.so"); //Lib to load
patches (building); // change to your patch name
rhoInf 1.225; //Reference density for fluid
CofR (0 0 0); //Origin for moment calculations
}
forceCoeffs
{
type forceCoeffs;
functionObjectLibs ("libforces.so");
patches (building); //change to your patch name
rhoInf 1.225;
CofR (0 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 0);
magUInf 11.2;
lRef 45;
Aref 45;
}
);

mgz1985 August 7, 2008 02:57

Hi Ivan, I tried what u sai
 
Hi Ivan,

I tried what u said but it does not still display the directory. If you do not mind can u please take a look at my controlDict file and tell me where is the error. I am posting it here. I copied the patch u have put above and made the changes but still.

I just want to see the directory.

/attach{text}

mgz1985 August 7, 2008 02:58

Hi Ivan, I tried what u sai
 
Hi Ivan,

I tried what u said but it does not still display the directory. If you do not mind can u please take a look at my controlDict file and tell me where is the error. I am posting it here. I copied the patch u have put above and made the changes but still.

I just want to see the directory.

/attach{ }

mgz1985 August 7, 2008 02:59

Hi Ivan, I tried what u sai
 
Hi Ivan,

I tried what u said but it does not still display the directory. If you do not mind can u please take a look at my controlDict file and tell me where is the error. I am posting it here. I copied the patch u have put above and made the changes but still.

I just want to see the directory.

\attach { }

mgz1985 August 7, 2008 03:01

\attach {mayank}
 
\attach {mayank}

mgz1985 August 7, 2008 03:02

http://www.cfd-online.com/Ope
 
http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif controlDict

ivanwhlau August 7, 2008 03:56

There is a typo. Should the p
 
There is a typo. Should the patch be "fixedWall" instead of "fiexdWall"?

mgz1985 August 7, 2008 04:53

hi Ivan, I corrected the ty
 
hi Ivan,

I corrected the typo but still there is no change. Still can not get the directory in the case directory or anywhere.

Is there anychanges to be made in some other files of the software library or what

ivanwhlau August 7, 2008 13:18

Well, I test your controlDict
 
Well, I test your controlDict with tutorials/icoFoam. It WORKS if I only paste your "function" part at the end. Then I replace the controlDict with your controlDict. it doesn't work. You may try and compare.


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