CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF in Cylindrical Coordinate (

mas_viper August 22, 2011 02:51

UDF in Cylindrical Coordinate
Hi guys,
I am a newbie in UDF world and I need some help for a simple UDF problem.
I have a 3d turbo setup and i need to have tangential velocity profile in inlet as a function of "r" in cylindrical coordinate. I had no idea about C programing and UDF so I used Fluent sample for inlet boundary and changed it to this:

#include "udf.h"
real x[ND_ND];
real y[ND_ND];
real xx;
real yy;
face_t f;

begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */
yy = y[1];
xx = x[1];

F_PROFILE(f,thread,index) = 0.00002*(xx*xx+yy*yy)*1000000-0.028*sqrt(xx*xx+yy*yy)*1000+11.565;

:confused::mad:Clearly it did not work because I did not know what I was doing!!! please helpme to change this UDF to give me velocity in cylindrical coordinate as "0.00002*r^2*1000000-0.028*r*1000+11.565" where "r" is radial distance from 0,0,0
Thank you :)

Erny August 22, 2011 05:46

If I am not mistaken the;-


Should give you the x,y,z coordinates for the cell such as;-
x[0] = x
x[1] = y
x[2] = z

mas_viper August 22, 2011 06:43

Thank you so much! It is so easy :p

donmezayd April 18, 2012 06:55

i also have to define a parabolic tangential profile but the velocity values computed by the udf does not match with the real values. help please!

#include "udf.h"
real x[ND_ND]; /* this will hold the position vector */
real r,R,omega;
face_t f;

F_PROFILE(f,t,i) = (omega*R*R/r)*(1-exp(-r*r/R*R));

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