CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF DPM Unsteady (

Lourival February 23, 2006 09:34

UDF DPM Unsteady
Hy everybody.

I'm trying to write a quite simple UDF to obtain some simple values of the particles flow.

So, I'm using the DEFINE_DPM_BC to obtain the position and the velocity of the particle that hit the wall. Also I'm using the LES turbulence model with 3D Unsteady solver with a group injection of 5 stream.

I wrote this simple UDF, shown below, but althought this UDF is compiled without problem I don't have the file with the values of the particles that are hitting the wall.

Does anybody did something similar ?? Does anyone know why I can print to file those values ?



#include "udf.h"

DEFINE_DPM_BC(bc_leitura_imp, p, t, f, f_normal, dim)

{ real vx, px; real vy, py; real vz, pz; real diam ; int ID_part ; FILE *fp;

vx=p->state.V[0] ;

vy=p->state.V[1] ;

vz=p->state.V[2] ;

px=p->state.pos[0] ;

py=p->state.pos[1] ;

pz=p->state.pos[2] ;

diam=p->state.diam ;

ID_part= p->part_id ;

fp = fopen("teste_export.txt","a+");

fprintf(fp,"ID %d", ID_part);


fprintf(fp,"Vel X %f", vx);


fprintf(fp, "Vel Y %f", vy);


fprintf(fp, "Vel Z %f", vz);


fprintf(fp,"Pos X %f", px);


fprintf(fp, "Pos Y %f", py);


fprintf(fp, "Pos Z %f", pz);


fprintf(fp, "Diam %f", diam);



return PATH_ABORT;


HS February 23, 2006 13:38

Re: UDF DPM Unsteady

I have actually done something similar that seemed to work just fine. I don't know what your problem is, I cannot see it in the code... Are you sure that the particles actually hit the wall during your simulation? You could put a simple Message-macro call within the code so that you will actually see in FLUENT whether the bc is being executed or not.

Also, I am not sure why you use "a+" as the mode for fopen? Try using only "a" instead. That should work fine.

Hope this helps!


Lourival February 23, 2006 13:56

Re: UDF DPM Unsteady
Hi Henrik, thanks a lot for you msn...

Well my problem is something like air flowing around a tube and on this tube I want to know the velocities, position and etc.. of the particles that hit the wall.

So, I did a test, I set only a message on the console of the FLUENT something like:

DEFINE_DPM_BC (....) { Message(" The UDF has been used"); return PATH_ABORT ; }

But I got none of this on the console, after that I shoot down the UDF and I am using the "escape" option of the Fluent model for the Wall and the FLUENT says:

number tracked: 600, escaped: 0, aborted: 0, trapped: 0, evaporated: 0, incomplete: 0

I guess that is something wrong with my physical model, but I don't know where...

Lourival February 23, 2006 15:22

Re: UDF DPM Unsteady
Hey Henrik, I got the error... The problem was that the particle was too light so, it wasn't hitting the tube. I increased the density and every thing was OK...

Thanks for your attention

Lourival February 24, 2006 08:21

Re: UDF DPM Unsteady
I use the "a+" to append a text to the end of my file. And if the file doesn't exist then it is created...


HS February 24, 2006 08:36

Re: UDF DPM Unsteady
If it works fine, then it's probably OK :)

I use only "a" to do the same thing, and it works just fine too.

Cheers, Henrik

All times are GMT -4. The time now is 20:17.