CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

Printing out forces in 1.6.x

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 26, 2010, 11:13
Default Printing out forces in 1.6.x
  #1
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
Hi all,

I'm quite new to OpenFOAM and CFD and general so please be nice .

I'm just practicing different setups right now and I'm trying to determine the drag on a cylinder. I read in previous posts about using the forces library so I'm trying to get that going. It says that I should see a created file in each of my time interval folders, but I see nothing. My functions section in my controlDict looks like:

functions
(
forces
{
type forces;
functionObjectLibs ("libforces.so");
patches (cylinder);
rhoInf 1.0;
CofR (-0.5 0 0);
outputControl outputTime;
outputInterval 0.01;
}
);

It compiles fine (using pisoFoam) but nothing is printed out afterward. Any help would be really appreciated.

Thanks!
ozzythewise is offline   Reply With Quote

Old   April 27, 2010, 02:28
Default Printing out forces in 1.6.x
  #2
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 322
Rep Power: 8
ata is on a distinguished road
Hi Jeff
I have your problem too.
ata is offline   Reply With Quote

Old   April 27, 2010, 08:53
Default
  #3
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
I've checked out a bunch of threads and what I have should just work but I can't seem to get it going. I'm sure it's something silly but I can't for the life of me figure out what it is. If anyone else has anyone thoughts please let us know.
ozzythewise is offline   Reply With Quote

Old   April 27, 2010, 09:03
Default
  #4
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
which code are you using?

if you check the messages at the beginning it will warn you if something is wrong with the forces calculation, in which case it will turn it off.
It will create a forces directory and write the info to that directory.

here's my forces dictionary in controlDict and its for pisoFoam
Code:
    forces
    {
        type        forceCoeffs;
        functionObjectLibs ( "libforces.so" );
        outputControl timeStep;
        outputInterval 1;
        patches
        (
            cylinder
        );
		directForceDensity no;

        pName       p;
        UName       U;
        rhoName     rhoInf;
        //log         true;
        rhoInf      994.5;
        CofR        ( 0 0 0 );
        liftDir     ( 0 1 0 );
        dragDir     ( 1 0 0 );
        pitchAxis   ( 0 0 1 );
        magUInf     0.54;
        lRef        0.04;
        Aref2        0.0157;
        Aref        0.004;
        rhoRef      994.5;
    }
niklas is offline   Reply With Quote

Old   April 27, 2010, 09:15
Default
  #5
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
I'm at work right now so I can't check if I have any error messages but from what I remember I don't think I do. I noticed in your code though that your type is "forceCoeffs", I thought that was used for if you want to determine the coefficient of lift and drag instead of the specific force values. Also, what is "directForceDensity"

Thanks a ton!
ozzythewise is offline   Reply With Quote

Old   April 28, 2010, 21:32
Default
  #6
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
Ok nevermind there is errors. Here are the printouts:

--> 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.
--> 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.

Clearly something is wrong, does anyone know what these mean. I'll look online and post if I find a solution.

Thanks!
ozzythewise is offline   Reply With Quote

Old   April 28, 2010, 21:45
Default
  #7
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
Ok, it's actually a simple fix.

1) Add "rhoName rhoInf;" to your forces subcategory in controlDict (without the quotes)
2) Create a 0/rho file

The warnings should go away and you will get a "forces" file printout in your case folder. This will contain all the forces and moments at each time step.
ozzythewise is offline   Reply With Quote

Old   April 29, 2010, 03:01
Default Printing out forces in 1.6.x
  #8
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 322
Rep Power: 8
ata is on a distinguished road
Hi Jeff
Thank you very much. I'll exam your offer and inform you if I have a problem.
Best regards

Ata
ata is offline   Reply With Quote

Old   April 29, 2010, 06:28
Default
  #9
Senior Member
 
Join Date: Feb 2010
Posts: 213
Rep Power: 8
vaina74 is on a distinguished road
I have a similar problem. In 1.6 I included the following lines in my controlDict:
Code:
functions
{
    forces
    {
        type        forces;
        functionObjectLibs ( "libforces.so" );  // lib to load
        outputControl timeStep;
        outputInterval 1;
        patches
        (
            wall  // change to your patch name
        );
        // name of fields
        pName       p;
        UName       U;
        log         true; // dump to file
        rhoInf      1025;
        CofR        ( 0 0 0 );
    }
    forcesCoeffs
    {
        type        forceCoeffs;
        functionObjectLibs ( "libforces.so" );  // lib to load
        outputControl timeStep;
        outputInterval 1;
        patches
        (
            wall  // change to your patch name
        );
        // name of fields
        pName       p;
        UName       U;
        log         true; // dump to file
        rhoInf      1025;
        CofR        ( 0 0 0 );
        liftDir     ( 0 1 0 );
        dragDir     ( 1 0 0 );
        pitchAxis   ( 0 0 0 );
        magUInf     7.30;
        lRef        0.319;
        Aref        0.001595;
    }
}
and it perfectly works. In these days I'm trying to install OpenFOAM1.6.x - I had a gcc conflict - and the code doesn't work (incompressible case)! I have this output:
Code:
--> 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.
--> 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.
vaina74 is offline   Reply With Quote

Old   April 29, 2010, 08:30
Default
  #10
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
Hey vaina, that is the exact same problem I had. You need to do the following 2 things:

1) Add "rhoName rhoInf;" (without the quotes) to your controlDict file before you enter "rhoInf 1025;"
2) Create a 0/rho file.

I imagine you will have to do #1 for your forcecoeffs as well, but I didn't care about the coefficients in my case so I didn't bother.

When you do both of those the error messages will disappear and you will create a "forces" file in your case directory with all the information in it that you need.

Good luck
ozzythewise is offline   Reply With Quote

Old   April 29, 2010, 11:17
Default
  #11
Senior Member
 
Join Date: Feb 2010
Posts: 213
Rep Power: 8
vaina74 is on a distinguished road
I read your tip, but I posted becouse I hope someone can explain what's the difference. I can't understand why my code works in OF1.6 and doesn't in OF1.6.x. Another question: what should I write in 0/rho file? I have an incompressible case.
Thank you for your help.
vaina74 is offline   Reply With Quote

Old   April 29, 2010, 11:25
Default
  #12
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
Hey viana,

That's strange because I'm running 1.6.x and that code worked for me. Only suggestion is to double check that you aren't missing any ";" or something silly like that. Do you get any error messages?

For the 0/rho file, I'm not sure what your test case is like but essentially for me I just did:

type fixedValue;
Value 1.2; //air

for every place in my simulation that had fluid. For outlet of my control volume I used zeroGradient and I can't quite remember what I used for my surfaces but I believe it was zeroGradient as well (computer not with me atm).
ozzythewise is offline   Reply With Quote

Old   April 29, 2010, 21:21
Default
  #13
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 7
ozzythewise is on a distinguished road
Also, if anyone knows how to print out the .dat file that this creates that contains the forces I would really appreciate that!

Thanks
ozzythewise is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forces in V1.6 terrybarnaby OpenFOAM 71 July 8, 2014 10:42
Reading forces from previous time step within solver SD@TUB OpenFOAM Programming & Development 0 March 14, 2010 07:58
Forces calulated through pressure LVDH OpenFOAM Post-Processing 2 February 26, 2010 04:15
Calculate forces without hydrostatic pressure geir_oye FLUENT 4 November 12, 2009 10:12
Valve Forces in CFdesign Mike Clapp Main CFD Forum 3 March 8, 2001 15:09


All times are GMT -4. The time now is 14:15.