CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Printing out forces in 1.6.x (http://www.cfd-online.com/Forums/openfoam-solving/75454-printing-out-forces-1-6-x.html)

ozzythewise April 26, 2010 11:13

Printing out forces in 1.6.x
 
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!

ata April 27, 2010 02:28

Printing out forces in 1.6.x
 
Hi Jeff
I have your problem too.

ozzythewise April 27, 2010 08:53

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.

niklas April 27, 2010 09:03

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;
    }


ozzythewise April 27, 2010 09:15

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 April 28, 2010 21:32

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 April 28, 2010 21:45

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.

ata April 29, 2010 03:01

Printing out forces in 1.6.x
 
Hi Jeff
Thank you very much. I'll exam your offer and inform you if I have a problem.
Best regards

Ata

vaina74 April 29, 2010 06:28

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.


ozzythewise April 29, 2010 08:30

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

vaina74 April 29, 2010 11:17

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.

ozzythewise April 29, 2010 11:25

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 April 29, 2010 21:21

Also, if anyone knows how to print out the .dat file that this creates that contains the forces I would really appreciate that!

Thanks


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