CFD Online Logo CFD Online URL
Home > Forums > FLUENT

UDF (write a data file) problem

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

LinkBack Thread Tools Display Modes
Old   July 28, 2005, 20:36
Default UDF (write a data file) problem
lichun Dong
Posts: n/a
Hi, all:

I am modeling a liquid drop movement on a surface and need to calculate the mass of the liquid drop. Therefore, I wrote a UDF, (actually a DEFINE_RW_File Macro) and try to save a data file. The code seemed to work, no any problem was showed during compiling or interpreting, however, I can not see any data file was saved, The mmanual says that once I save a data file, the UDF will work and a data file shoula be saved? Am I right?

Therfore, my question is: How to run a DEFINE_RW_FILE udf? would a data file be saved once the udf works properlly?

Thanks very much for your help and suggestion

Lichun Dong

The followed is my code.

#include "udf.h"

DEFINE_RW_FILE(weight_center, filep)

Domain *d


face_t f;

cell_t c;

Thread *t;

d = Get_Domain(1); /* Get the domian using Fluent utility */

real volume;

real vol_tot = 0;

real position[ND_ND],x,y,z;

real xadjvol = 0;

real yadjvol = 0;

real zadjvol = 0;

real xcenter;

real ycenter;

real zcenter;

real flowt;

real vowater;

/* Loop over all cell threads in the domian */



/* Loop over all cells */

begin_c_loop(c, t)


volume = C_VOLUME(c,t);

vowater = C_VOF(c, t[1]);

vol_tot =+ volume*vowater;

C_CENTROID(position, c, t);

x = position(0);

y = pisition(1);

z = position(2);

xadjvol = xadjvol + x*vowater*volume;

yadjvol = yadjvol + y*vowater*volume;

zadjvol = zadjvol + z*vowater*volume;



xcenter = xadjvol/vol_tot;

ycenter = yadjvol/vol_tot;

zcenter = zadjvol/vol_tot;

flowt = RP_GET_Real("flow-time");

fprintf(filep, "%d", flowt, "%d", xcenter, "%d", ycenter, "%d", zcenter);

} }

  Reply With Quote

Old   July 29, 2005, 03:16
Default Re: UDF (write a data file) problem
Posts: n/a
As I understand the UDF manual, the DEFINE_RW_FILE macro does not by itself write or read any files. It only determines, what additional information is written/read to/from the case or data files that you write/read yourself manually or in a script.

Maybe as you set up a small test model and write the case/data file in clear text (not binary), you can inspect the files to see if your data is written.

I haven't used this macro myself yet though.
  Reply With Quote

Old   July 29, 2005, 11:39
Default Re: UDF (write a data file) problem
lichun Dong
Posts: n/a

Thank you for your response. Have you used DEFINE_ON_DEMAND and save data using C_UDMI?

I will be very appreciated if anyone can give me some advice.

Lichun dong
  Reply With Quote


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
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 18:18
Problem installing on Ubuntu 9.10 -> 'Cannot open : No such file or directory' mfiandor OpenFOAM Installation 2 January 25, 2010 10:50
UDF Getting data from file jreig FLUENT 0 July 10, 2009 08:07
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00

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