CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Error message udf file (https://www.cfd-online.com/Forums/fluent-udf/90409-error-message-udf-file.html)

Keskidi July 9, 2011 03:46

Error message udf file
 
Hello,
i want to introduce a velocity profile at the inlet of a 3D tube.
My udf file is:
#include "udf.h"
DEFINE_PROFILE(inlet_z_velocity,thread,index)
{
real z[ND_ND];
real x;
real y;
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(z,f,thread);
x = x[0];
y = x[1];
F_PROFILE(f,thread,index) = 0.217*pow(pow((pow(y,2)+pow(x,2)),0.5)/3.9,1/7);
}
end_f_loop(f,thread)
}


When i put it in fluent i've got the message
line11: subscripted expression is not an array or pointer : double

Thks for your help

Josyula July 9, 2011 05:06

Hi,
I think z = x[2]; has to be added.
Check and see.

Keskidi July 9, 2011 05:35

Now fluent read the file but it is not what i expect
To be more precise, the face is on the XY plane and the velocity orientated in the z direction.
But if i check the initialization, the profile is flat.
I modified the file like that:#include "udf.h"
DEFINE_PROFILE(inlet_z_velocity,thread,index)
{
real z[ND_ND];
real x;
real y;
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(z,f,thread);
x = z[1];
y = z[2];
F_PROFILE(f,thread,index) = 0.217*pow(pow((pow(y,2)+pow(x,2)),0.5)/3.9,1/7);
}
end_f_loop(f,thread)
}

Micael July 9, 2011 17:19

You want to calculate velocity magnitude in z direction?

If I understand what you want, that could be like that:
Code:

#include "udf.h"
DEFINE_PROFILE(inlet_z_velocity,thread,index)
{
real coord[ND_ND];  /* face centroid coordinate */
real x;
real y;
face_t f;
 
begin_f_loop(f,thread)
  {
    F_CENTROID(coord,f,thread);
    x = coord[0];
    y = coord[1];
    F_PROFILE(f,thread,index) = 0.217*pow(pow((pow(y,2)+pow(x,2)),0.5)/3.9,1./7);
}
  end_f_loop(f,thread)
}

However, the main reason why you got a flat profil is because of "1/7". That is just zero in C language, because operation on 2 integers still gives an integer (integer value of 1/7 is zero). I change it for 1./7 in the code above.

Keskidi July 9, 2011 17:48

Yes exactly.
It's working well with 1./7
Thanks a lot


All times are GMT -4. The time now is 13:23.