CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF (write a data file) problem (

lichun Dong July 28, 2005 20:36

UDF (write a data file) problem
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);

} }

CFD-novice July 29, 2005 03:16

Re: UDF (write a data file) problem
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.

lichun Dong July 29, 2005 11:39

Re: UDF (write a data file) problem

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

All times are GMT -4. The time now is 10:16.