CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

how to write a scalar value to a file ????

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 7, 2013, 12:00
Default how to write a scalar value to a file ????
  #1
Member
 
Samer
Join Date: Jan 2013
Posts: 31
Rep Power: 13
SamerAli is on a distinguished road
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
SamerAli is offline   Reply With Quote

Old   May 7, 2013, 13:19
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
ngj is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 7 December 15, 2020 13:06
[Helyx OS] Helyx-OS (GUI for SnappyHexMesh elvis OpenFOAM Community Contributions 210 January 30, 2017 18:57
which tutorial can find that include Riemann boundary condition? immortality OpenFOAM Running, Solving & CFD 12 May 3, 2013 18:21
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08


All times are GMT -4. The time now is 08:24.