CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Beginner having trouble with UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 16, 2013, 00:43
Default Beginner having trouble with UDF
  #1
New Member
 
Join Date: May 2013
Posts: 4
Rep Power: 13
owenmeanie is on a distinguished road
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:

node definition shadows previous definition
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!

Last edited by owenmeanie; May 16, 2013 at 01:35.
owenmeanie is offline   Reply With Quote

Old   May 16, 2013, 00:53
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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)
blackmask is offline   Reply With Quote

Old   May 16, 2013, 01:34
Default
  #3
New Member
 
Join Date: May 2013
Posts: 4
Rep Power: 13
owenmeanie is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)

Thank you for your reply!
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!
owenmeanie is offline   Reply With Quote

Old   May 16, 2013, 02:15
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Try compiling your UDF file rather than interpreting.
blackmask is offline   Reply With Quote

Old   May 16, 2013, 16:55
Default
  #5
New Member
 
Join Date: May 2013
Posts: 4
Rep Power: 13
owenmeanie is on a distinguished road
Quote:
Originally Posted by blackmask View Post
Try compiling your UDF file rather than interpreting.
That fixed the problem. Thanks a lot!
owenmeanie is offline   Reply With Quote

Old   February 8, 2019, 05:01
Default normalise the y value
  #6
New Member
 
Mark Taylor
Join Date: Feb 2019
Posts: 1
Rep Power: 0
markrobintaylor is on a distinguished road
As far as I can see you have a small error that could potentially ruin your profile.

When you define the y_p variable, you should have y_p=2*(y-midpoint)/h;

this will normalise the y co-ordinate to between -1 and 1 , only then will your formula for the parabolic profile (1-y_p*y_p) make sense.
markrobintaylor is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12
Simulation with UDF for species mass fraction and velocity profile virgy Fluent UDF and Scheme Programming 8 February 7, 2012 05:30
UDF programming fullmonty FLUENT 5 June 30, 2011 03:40
Trouble: Sandia UV UDF on FLUENT 12.0.16 RPJones Fluent UDF and Scheme Programming 31 May 25, 2011 12:15
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03


All times are GMT -4. The time now is 18:36.