CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   how to write a scalar value to a file ???? (http://www.cfd-online.com/Forums/openfoam-programming-development/117385-how-write-scalar-value-file.html)

SamerAli May 7, 2013 12:00

how to write a scalar value to a file ????
 
Dear All
I am trying to calculate the lift and drag forces on a (cylinder + plate) and i would love to extract the total lift and the total drag and write them in a file at each writing interval, how would i do that ???
I am using Openfoam 1.6-ext, and this is the header file for lift and drag calculations :

scalar lift = 0;
scalar drag = 0;

const vectorField& Sfp = mesh.boundary()[plateID].Sf();
forAll(p.boundaryField()[plateID], facei)
{
vector faceForce = p.boundaryField()[plateID][facei] * Sfp[facei];
lift += vector(0,1,0) & faceForce;
drag += vector(1,0,0) & faceForce;
}

const vectorField& Sfc = mesh.boundary()[cylinderID].Sf();
forAll(p.boundaryField()[cylinderID], facei)
{
vector faceForce = p.boundaryField()[cylinderID][facei] * Sfc[facei];
lift += vector(0,1,0) & faceForce;
drag += vector(1,0,0) & faceForce;
}

how do i extract and write the scalar lift and the scalar drag to a file ??

Best regards

ngj May 7, 2013 13:19

Hi Samer,

It sounds like you are trying to accomplish the functionality in the forces and forceCoeffs functionObjects, which can be added at runTime.

Search the forum for its use and you can also find an example on how to extract the forces in this tutorial:

Code:

<path_to_tutorials>/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_simpleFoam/system/controlDict
There are also other tutorials using the forces, and you can find these by typing the following in the command line (with a sourced OF-version)

Code:

tut; find ./ -name "controlDict" -type f | xargs grep forces
Kind regards,

Niels


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