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

How to use input parameter in UDF?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By pakk
  • 1 Post By ghost82

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 20, 2015, 04:45
Default How to use input parameter in UDF?
  #1
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Hello I have 3D channel flow I wrote a UDF for velocity profile at inlet to get fully developed flow I need to enter average velocity into my UDF as input parameter? How i can do this please? any help is mandatory?

mariam
mariam.sara is offline   Reply With Quote

Old   November 22, 2015, 02:48
Default
  #2
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Nobody know my question?

mariam
mariam.sara is offline   Reply With Quote

Old   November 23, 2015, 07:25
Default
  #3
Senior Member
 
Join Date: Mar 2014
Posts: 375
Rep Power: 13
hwet is on a distinguished road
Not sure but the way it sounds "average velocity", I would just use a velocity inlet condition, thats what i suppose it does? why do you even need a UDF for an average profile?
hwet is offline   Reply With Quote

Old   November 23, 2015, 08:17
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Are you asking us for help on the udf that you wrote? You are the creator, so you should know best how it works...
And anyway, how do you think we can tell you how your own udf works if you don't give us the code? We are not telepathic...
pakk is offline   Reply With Quote

Old   November 23, 2015, 11:38
Default
  #5
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Thanks hwet for the replay. I want use different Uavg values at the udf because I want set different velocities for inlets because I have heat exchanger of two fluids (water and air) contain several inlets for air (its number reach 100) hence I need 100 udf so I just want set Uavg as an input parameter in the udf and let it change inside the udf hope this clear??

Quote:
Originally Posted by hwet View Post
Not sure but the way it sounds "average velocity", I would just use a velocity inlet condition, thats what i suppose it does? why do you even need a UDF for an average profile?
mariam.sara is offline   Reply With Quote

Old   November 23, 2015, 11:45
Default
  #6
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Mr. pakk my question not about the udf and if it working or no. My question about how i can using parameter in udf (see photo)? i need steps how to really applied a parameter to the udf?

Quote:
Originally Posted by pakk View Post
Are you asking us for help on the udf that you wrote? You are the creator, so you should know best how it works...
And anyway, how do you think we can tell you how your own udf works if you don't give us the code? We are not telepathic...
Attached Images
File Type: jpg hhh.jpg (115.4 KB, 187 views)
mariam.sara is offline   Reply With Quote

Old   November 25, 2015, 03:34
Default
  #7
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Hi pakk to be more specific I have a UDF which requires a real parameter. Is there a way to give this parameter different values, without having to modify and recompile the udf again? if you want to have a look on the udf i will post it?

Quote:
Originally Posted by pakk View Post
Are you asking us for help on the udf that you wrote? You are the creator, so you should know best how it works...
And anyway, how do you think we can tell you how your own udf works if you don't give us the code? We are not telepathic...
mariam.sara is offline   Reply With Quote

Old   November 25, 2015, 03:42
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by mariam.sara View Post
Hi pakk to be more specific I have a UDF which requires a real parameter. Is there a way to give this parameter different values, without having to modify and recompile the udf again? if you want to have a look on the udf i will post it?
You can set a parameter in the text user interface. If you want to set a parameter with the name 'tui_alpha' to the value 0.05, type the following in Fluent:
Code:
(rp-var-define 'tui_alpha 0.05 'real #f)
To read this parameter into the c-code udf, you can use the following code in your udf:

Code:
udf_alpha = RP_Get_Float("tui_alpha");
For more help, look for "rp-var-define" and "RP_Get_Float" in the Fluent manual.
mariam.sara likes this.
pakk is offline   Reply With Quote

Old   November 28, 2015, 15:18
Default
  #9
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Thanks pakk for the valuable answer. Actually I was followed the steps mentioned in user guide and I type the option for my average velocity as below in text interface:

rp-var-define 'Uavg 0.05' real #f

the problem when i compile my udf the following error appear to me:

Error: rpgetvar: Uave: undefined variable

what the problem? knowing i was added the variable in the UDF and here is copy of the full UDF

/************************************************** *******************
UDF for specifying steady-state velocity profile boundary condition
************************************************** ********************/
#include"udf.h"
/* Geometry description */
#define h 0.002 /*height duct in m */
#define w 0.005 /*weidth duct in m */
#define s 0.004 /*step weidth duct in m */
/*********** ****************************
Inlet velocity profile
***************************************/
DEFINE_PROFILE(inlet_z1_velocity,t,i)
{
real x,z1[ND_ND];
real radx,rady,;
real N1,M1,Alfa;
real y;
face_t f;
real Uave=RP_Get_Real("Uave");
Alfa =(w/h); /* Aspect ratio of the inlet duct */
M1 = 1.7 + 0.5 * pow(fabs(Alfa),-1.4);
if (Alfa <= (1/3))
N1 = 2.0 ;
else
{
N1 = 2 + 0.3*(Alfa - (1/3));
}
/*********************************************/
begin_f_loop(f,t)
{
F_CENTROID(z1,f,t);
y = z1[1];
x = z1[2];
rady = (1.0-pow(fabs(y-h/2)/(h/2),N1));
radx = (1.0-pow(fabs(x-((w/2)+ s))/(w/2),M1));
F_PROFILE(f,t,i) = Uave*((M1+1)/M1)*((N1+1)/N1)*rady*radx;
}
end_f_loop(f,t)
}
mariam.sara is offline   Reply With Quote

Old   November 29, 2015, 05:58
Default
  #10
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
rp-var-define 'Uavg 0.05' real #f

real Uave=RP_Get_Real("Uave");


Then it is not rp-var-define 'Uavg 0.05' real #f
but
rp-var-define 'Uavg 0.05 'real #f
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   November 29, 2015, 13:38
Default
  #11
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Thanks ghost for the reply. I not understand your replay clearly may you tell me what the error with my expression? It seem you wrote similar expression to the one I wrote?

mariam

Quote:
Originally Posted by ghost82 View Post
rp-var-define 'Uavg 0.05' real #f

real Uave=RP_Get_Real("Uave");


Then it is not rp-var-define 'Uavg 0.05' real #f
but
rp-var-define 'Uavg 0.05 'real #f
mariam.sara is offline   Reply With Quote

Old   November 29, 2015, 13:40
Default
  #12
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
You defined Uavg as variable but you call Uave in udf, which is not defined. So, change Uavg to Uave
mariam.sara likes this.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   November 29, 2015, 15:44
Default
  #13
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
I fixed this error but the current error shown in picture is still appearing to me as soon as i open fluent?? what its reason?

Quote:
Originally Posted by ghost82 View Post
You defined Uavg as variable but you call Uave in udf, which is not defined. So, change Uavg to Uave
Attached Images
File Type: jpg ff.jpg (122.5 KB, 65 views)
mariam.sara is offline   Reply With Quote

Old   November 29, 2015, 15:50
Default
  #14
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Fluent cannot find the libudf folder with compiled udf to load it, nor the .c file to autocompile udf.
Do you have the libudf folder or the .c file in the same folder in which you have the .cas?
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   November 29, 2015, 15:59
Default
  #15
Senior Member
 
Join Date: Jan 2011
Posts: 339
Rep Power: 16
mariam.sara is on a distinguished road
Cannot find the libudf folder? may you tell me where i can find it please?

Quote:
Originally Posted by ghost82 View Post
Fluent cannot find the libudf folder with compiled udf to load it, nor the .c file to autocompile udf.
Do you have the libudf folder or the .c file in the same folder in which you have the .cas?
mariam.sara is offline   Reply With Quote

Old   November 29, 2015, 16:03
Default
  #16
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
You start with the cas and .c files in some folder; when you compile the .c file fluent automatically creates the "libudf" folder inside the folder where you have .c and .cas files. Inside the libudf folder there are other folders and your compiled udf. If you don't have the libudf folder fluent searches for the .c file and if it finds it, it will try to automatically recompile the code, recreating the libudf folder.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   December 1, 2015, 01:54
Default don't understand some of the terms in UDF
  #17
Member
 
Mansoor Ahmed
Join Date: Apr 2014
Location: https://t.me/pump_upp
Posts: 47
Rep Power: 12
engrmansoor2534 is on a distinguished road
Send a message via ICQ to engrmansoor2534 Send a message via AIM to engrmansoor2534 Send a message via Yahoo to engrmansoor2534
Can anyone please explain the purpose of the terms used in the following UDF
Code:
#include"udf.h"
DEFINE_GRID_MOTION(twist,domain,dt,time,dtime)
{
Thread *tf = DT_THREAD(dt);
face_t f;
Node *v;

real NV_VEC(axis);
real delta,xaxis,yaxis,teta,xn,yn,dx,dy,H;
int n;


H = 0.1; /*z-dimension of the model*/
teta = 10*3.14/180; /*rotation angle*/


begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
/* update node if the current node has not been previously
visited when looping through previous faces */
if ( NODE_POS_NEED_UPDATE (v))
{
/* indicate that node position has been update
so that it's not updated more than once */
NODE_POS_UPDATED(v);
xn = cos(teta)*NODE_X(v)-sin(teta)*NODE_Y(v);
yn = sin(teta)*NODE_X(v)+cos(teta)*NODE_Y(v);
dx = xn-NODE_X(v);
dy = yn-NODE_Y(v);
xaxis = dx/sqrt(pow(dx,2) + pow(dy,2));
yaxis = dy/sqrt(pow(dx,2) + pow(dy,2));
NV_D(axis, =, xaxis,yaxis, 0.0);
delta = sqrt(pow(dx,2) + pow(dy,2))*NODE_Z(v)/H;
NV_V_VS(NODE_COORD(v), =, NODE_COORD(v), +, axis,*,delta);


}
}
}
end_f_loop(f,tf);
}
this UDF produces a twist in a channel. I got it from one of cfd-online posts. I need to know the physical meaning of the lines in BOLD.
thank you
engrmansoor2534 is offline   Reply With Quote

Old   December 2, 2015, 14:38
Default
  #18
Senior Member
 
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 21
brunoc is on a distinguished road
It's math. Everything it does is written there, and the functions (NODE_X(), NODE_Y(), NV_D(), etc) are in the manual.

What don't you understand?
brunoc 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
Use Input parameter in the monitor window drag and lift calculation Anna Tian FLUENT 5 September 1, 2014 20:44
parse error while interpreting udf Kristin Fluent UDF and Scheme Programming 3 March 15, 2012 06:43
Tablular values as input to UDF BS FLUENT 0 March 30, 2008 18:59
DEFINE_GEOM UDF Problems Pat FLUENT 0 August 14, 2003 13:16
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


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