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/)
-   -   Drag and lift force using OpenFoam14 (https://www.cfd-online.com/Forums/openfoam-solving/58675-drag-lift-force-using-openfoam14.html)

hardy August 15, 2007 10:54

Hello! I would kindly like
 
Hello!

I would kindly like to ask if someone could describe to me what is the easiest way to write drag- and lift- force for each time step using turbFoam.

I have seen other threads on this subject with several references to the function dragCoefficient. Is this function accessible in OpenFoam 1.4 or is there some other way to do it??

Regards!
/H

philippose August 15, 2007 11:04

Hello Hardy, I am still at
 
Hello Hardy,

I am still at work, but since you sound quite hurried.... question is, do you want to calculate the lift and drag during the simulation, or do you want to do it as a post-processing step once the simulation is done??

Anyway.... have a look at the folder:

"OpenFOAM/OpenFOAM-1.4/src/postProcessing/incompressible/liftDrag"

The code in there should give you more than a simple "Head-start" :-)!

Enjoy!

Philippose

hardy August 16, 2007 02:41

Hello again and thank you!
 
Hello again and thank you!

Yes, I would like to calculate the forces during the simulation.

Hmmm, in my file structure there is no "postProcessing" folder within the "src" folder as you suggests. Is there something wrong with my system? Canīt find such folder anywhere else either.

/H

paka August 16, 2007 03:35

Hardy, To install liftDrag
 
Hardy,

To install liftDrag tool in OpenFOAM 1.4, please follow instructions included here, those describe how to import liftDrag from version 1.2:
http://www.cfd-online.com/OpenFOAM_D...es/1/2299.html

Below address also includes updated (I guess) and tided up version of liftDrag tool:
http://www.cfd-online.com/OpenFOAM_D...es/1/1604.html

I also know there were some issues with that tool validity, but I'm not sure.

For more questions about liftDrag try to follow Search Utility on the left side and type 'liftDrag'.

Regards and good luck,
Krystian

hardy August 21, 2007 06:24

Thank you once again! I hav
 
Thank you once again!

I have now imported liftDrag from version 1.2 and it compiled well!

I have looked through the liftDrag code and all other threads about liftDrag but I am still confused about how to use it?

As being a beginner in OpenFOAM and C++ I wonder if someone could point out a way for me how to use liftDrag, or parts of it, in order to get drag data from each time step of my simulation.

Donīt hesitate to treat me as stupid if that would make thing easier.... :-)

/Hardy

msrinath80 August 22, 2007 19:14

Hardy. Tell me which solver yo
 
Hardy. Tell me which solver you are using and I will post the instructions.

msrinath80 August 22, 2007 19:15

oops, I already see you want t
 
oops, I already see you want to use turbFoam. I will post the instructions shortly.

msrinath80 August 22, 2007 19:57

Here you go. Place this file i
 
Here you go. Place this file in ~/OpenFOAM/OpenFOAM-1.4/applications/solvers/incompressible
and run the following command:
tar -xzvf turbFoam_1.tar.gz

Next enter the newly created turbFoam_1 directory and execute the following commands:

wclean && wmake

That's all. Your modified turbFoam_1 solver which calculates Lift/Drag forces in every time-step is ready for use.

There is one catch however. The code assumes a reference area of unity and also a reference velocity of unity. I personally find it easier to set the reference velocity and reference area to unity so that I can later find the exact drag and lift coefficients depending on the case by multiplying/dividing by the appropriate numbers.

If you don't follow something, drop a message here and I will get back to you. Good Luck!

Attachments:
http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif turbFoam_1.tar.gz

hardy August 23, 2007 04:12

Thank you very much! turbFo
 
Thank you very much!

turbFoam_1 is up and running! Now I just have to understand how it works so that I can make such modifications my self in the future :-)

/H

msrinath80 August 23, 2007 13:21

Good to know that it compiled
 
Good to know that it compiled without issues. The Drag/Lift computation was primarily done by Frank Bos. Search for his posts in this forum concerning Lift and Drag, you will find many useful threads.

PS: If you need to extract the Lift/Drag coefficients from the log file conveniently, using the foamLog command, you need to add the following 4 lines in your foamLog.db file (which is present in ~/OpenFOAM/OpenFOAM-1.4/bin)

#- Drag coefficient:
dragCoefficient/DragCoefficient = /DragCoefficient =

#- Pressure Drag coefficient:
pressureDragCoefficient/pressureDragCoefficient = /pressureDragCoefficient =

#- Viscous Drag coefficient:
viscDragCoefficient/viscDragCoefficient = /viscDragCoefficient =

#- Lift coefficient:
liftCoefficient/LiftCoefficient = /LiftCoefficient =

gemaforce April 3, 2008 02:05

Hi all, I'm referring to Srina
 
Hi all, I'm referring to Srinath's post earlier on.
-------------------------------------------------
Here you go. Place this file in ~/OpenFOAM/OpenFOAM-1.4/applications/solvers/incompressible
and run the following command:
tar -xzvf turbFoam_1.tar.gz

Next enter the newly created turbFoam_1 directory and execute the following commands:

wclean && wmake
------------------------------------------------

I've got a problem after this step. When I looked into FoamX again, I don't see a turbFoam_1 module. Or is it under turbFoam?

Thanks
Samuel

msrinath80 April 3, 2008 12:34

turbFoam_1 is simply a version
 
turbFoam_1 is simply a version of turbFoam that also prints the dimensionless force coefficients in the log file for every time step (or iteration). As it is a customized version, I think that you will basically need to edit some FoamX cfg file(s) and copy the turbFoam section and create a new turbFoam_1 section. Having come this far, I would expect that folks would have weaned themselves off FoamX as it is merely a graphical frontend to editing the dictionary files ;)

gemaforce April 7, 2008 21:24

Ok! I think I some sort know w
 
Ok! I think I some sort know what you mean! I just have a query as I'm really new to FoamX and the whole thing about C++, how do I edit the FoamX cfg files so that the coefficients can appear in the log file? After wmake, I ran the program with turbFoam again and the log file does not print the force coefficients =(

msrinath80 April 8, 2008 14:49

After wmake, I ran the program
 
After wmake, I ran the program with turbFoam again and the log file does not print the force coefficients =(

You need to run turbfoam_1 NOT turbfoam.

gemaforce April 8, 2008 21:07

I'll go and try running turbFo
 
I'll go and try running turbFoam_1 now and and see if it works this time! Thanks

gemaforce April 11, 2008 03:22

Hi Srinath! I tried it and
 
Hi Srinath!

I tried it and it works nicely! There is just one last problem that cropped up. I would like to find out the momentCoefficient value, so I uncommented the Lref and momentCoefficient statements. However, when I tried to compile again, it returns an error message saying that momentCoefficient is not declared in the scope. I did remember seeing it as a scalar somewhere in your script, but I'm not sure why it still says it isn't declared.

msrinath80 April 11, 2008 20:32

You need to add the relevant s
 
You need to add the relevant section for momentCoefficient in liftDrag.H. I'm pasting the code from OpenFOAM 1.2 (where I got the original liftDrag code). Including it in liftDrag.H should do the trick.

Foam::vector Foam::momentCoefficient
(
const volVectorField& U,
const volScalarField& p,
const dimensionedScalar& mu,
const word& patchName,
const vector& Uinf,
const scalar& Aref,
const scalar& Lref
)
{
if (mag(Uinf) < VSMALL)
{
FatalErrorIn
(
"vector momentCoefficient\n"
"(\n"
" const volVectorField& U,\n"
" const volScalarField& p,\n"
" const dimensionedScalar& mu,\n"
" const word& patchName,\n"
" const vector& Uinf,\n"
" const scalar& Aref,\n"
" const scalar& Lref\n"
")\n"
) << "Uinf is zero."
<< exit(FatalError);
}

const fvMesh& mesh = p.mesh();

label patchLabel = -1;

forAll (mesh.boundary(), patchi)
{
if (mesh.boundary()[patchi].name() == patchName)
{
patchLabel = patchi;
break;
}
}

vector pressureForceMoment;
vector viscousForceMoment;

if (patchLabel != -1)
{
pressureForceMoment = sum
(
mesh.Cf().boundaryField()[patchLabel]^
(p.boundaryField()[patchLabel]
*mesh.Sf().boundaryField()[patchLabel])
);

viscousForceMoment = sum
(
mesh.Cf().boundaryField()[patchLabel]^
(-mu.value()*U.boundaryField()[patchLabel].snGrad()
*mesh.magSf().boundaryField()[patchLabel])
);
}
else
{
pressureForceMoment = sum(vectorField(0));
viscousForceMoment = sum(vectorField(0));
}

scalar qRef = 0.5*magSqr(Uinf);
scalar Fref = qRef*Aref;
scalar Mref = Fref*Lref;

vector pressureCoeff = pressureForceMoment/Mref;
vector viscousCoeff = viscousForceMoment/Mref;

return (pressureCoeff + viscousCoeff);
}


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


You may also want to add the following in the beginning:

vector momentCoefficient
(
const volVectorField& U,
const volScalarField& p,
const dimensionedScalar& mu,
const word& patchName,
const vector& Uinf,
const scalar& Aref
);

Please be aware that you need to test the moment results you obtain with a reference like I did for lift/drag. Frank has Momentcoefficient working as you can see here [1]. Please check with him if you have further problems :-)

[1] http://www.cfd-online.com/OpenFOAM_D...es/1/1807.html

gemaforce April 13, 2008 20:44

Thank you so much Srinath! I w
 
Thank you so much Srinath! I will put in this section and try running again!

mou_mi June 19, 2008 11:31

Hello I have some questions
 
Hello

I have some questions about adjusting computeForces.H file.

1) Who I can find Aref?
for example in this model,
http://www.cfd-online.com/OpenFOAM_D...ges/1/8095.jpg
is the Aref hatched area, and I need also to multiply to depth Aref = [(10*5)-(1*1)]* 2
http://www.cfd-online.com/OpenFOAM_D...ges/1/8096.jpg

2) How can I set Umax?

Thank you
mou

ivanwhlau August 4, 2008 02:50

Hi, all, Will this turbF
 
Hi, all,
Will this turbFoam_1 work for version 1.5?
Thanks,
Ivan


All times are GMT -4. The time now is 01:05.