CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Beginner having trouble with UDF (https://www.cfd-online.com/Forums/fluent-udf/117830-beginner-having-trouble-udf.html)

 owenmeanie May 15, 2013 23:43

Beginner having trouble with UDF

Hello, I am learning FLUENT and I am trying to practice creating UDFs.
I was trying to create a UDF that would create a parabolic x-velocity boundary profile on an inlet that is parallel to the y-axis. There is an example like this on the UDF manual, but it requires the inlet to be centered at y = 0.

I decided to create one that would work for an inlet that is located anywhere.
Here is what I have:

#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity_profile, t, i)
{
real x[ND_ND]; /*2D or 3D?*/
real y_max;
real y_min;
real y_check, h, midpoint;
int n;
face_t f;
Node *node;

y_max = -1000000;
y_min = 1000000;

begin_f_loop(f,t) /*Loop through all faces of face thread */
{
f_node_loop(f,t,n) /* Loop through all nodes in face, n is node number */
{
node = F_NODE(f,t,n); /*get current node */
y_check = NODE_Y(node); /*real y coordinate of node*/

if (y_check > y_max)
{
y_max = y_check;
}
if (y_check < y_min)
{
y_min = y_check;
}
}
}
end_f_loop(f,t);

h= y_max-y_min;
midpoint = (y_max+y_min)/2;

begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y=x[1];
y_p = y-midpoint;
F_PROFILE(f,t,i) = 1-y_p*y_p;
}
end_f_loop(f,t);
}

However I keep getting this error when I try to interpret the function on FLUENT:

Error: C:\\Users\\USER\\Desktop\\ANSYS Practice\\parabolic_velocity_profile.c: line 24: type_size: don't know what to do with TYPE_STRUCT
Error: C:\\Users\\USER\\Desktop\\ANSYS Practice\\parabolic_velocity_profile.c: line 24: structure reference not implemented

Any help would be really appreciated. Thank you!

f_node_loop(f,t) /* Loop through all nodes in face, n is node number */

Where is the "n" referred in the comment? Please change to

f_node_loop(f,t, n)

 owenmeanie May 16, 2013 00:34

Quote:
 Originally Posted by blackmask (Post 427881) f_node_loop(f,t) /* Loop through all nodes in face, n is node number */ Where is the "n" referred in the comment? Please change to f_node_loop(f,t, n)

I actually had it there but for some reason removed it before copying the code to post the thread.
The message appeared before I took it out, and it still appears now that I put it back in. Sorry about that!

Try compiling your UDF file rather than interpreting.

 owenmeanie May 16, 2013 15:55

Quote:
 Originally Posted by blackmask (Post 427887) Try compiling your UDF file rather than interpreting.
That fixed the problem. Thanks a lot!

 All times are GMT -4. The time now is 08:47.