# How to write UDF programme inside FLUENT?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 26, 2009, 00:54 How to write an UDF programming inside FLUENT? #1 New Member   oscar Join Date: Mar 2009 Posts: 7 Rep Power: 10 I have a brick region..the front surface i make it as inlet and i would like to write a UDF programme for the inlet velocity which is parabolic shape.. eg: at the center of the inlet is the highest velociy. (a parabolic shape) secondly, left, right and behind surface i make it as pressure outlet and write a UDF programme for pressure different. Due to the brick region as a sea. and the lower surface is a seabed.. therefore if from top surface to lower surface(deeper) , the pressure will increase..(a triangle shape) May I know how to write a UDF programme for this..THX Last edited by coolyihao; March 26, 2009 at 22:19.

 March 26, 2009, 06:19 #2 Senior Member   Rami Ben-Zvi Join Date: Mar 2009 Posts: 148 Rep Power: 10 There is a detailed example of a parabolic velocity profile in the UDF manual (chapter 8). Once you learn how to do it, the pressure BCs would be easy to add.

 March 26, 2009, 06:49 #3 New Member   oscar Join Date: Mar 2009 Posts: 7 Rep Power: 10 ya..i saw it be4..but then i got the result that doesnt make sense..for example: i put X=0 , Y=1, Z=0..inside the grapgh, ya i get the parabolic shape which is 'u' shape..OR is it suppose a 'n' shape. But for the pressure difference is it necessary use this function?F_CENTROID(x,f,thread) regards

 March 28, 2009, 21:12 #4 New Member   Andrew Slezak Join Date: Mar 2009 Posts: 1 Rep Power: 0 yes, probably. f_centroid will return the position vector of the cell in 'x'. The solver should produce the pressure profile throughout your domain given appropriate initial and boundary conditions.

April 1, 2009, 02:07
#5
Member

Buddy
Join Date: Mar 2009
Location: P.R.C.
Posts: 30
Rep Power: 10
Quote:
 Originally Posted by Drew yes, probably. f_centroid will return the position vector of the cell in 'x'. The solver should produce the pressure profile throughout your domain given appropriate initial and boundary conditions.
there are two kinds of parallel functions such as begin _c_loop and begin_f_loop, can you tell me the differents bwteen face and cell?

and if the using of the cell will return the vector of it,what will return if we use face instead? O(∩_∩)O~

 March 8, 2016, 13:24 UDF for derivatives if fluctuating velocities #6 Member   Join Date: May 2013 Posts: 32 Rep Power: 6 Hello, Does anyone know how to calculate 1st derivatives (partial derivative) of the fluctuating velocities in UDF? Appreciate any help. Thanks,

March 8, 2016, 14:23
#7
Senior Member

Join Date: May 2014
Posts: 271
Rep Power: 6
Quote:
 Originally Posted by maphd Hello, Does anyone know how to calculate 1st derivatives (partial derivative) of the fluctuating velocities in UDF? Appreciate any help. Thanks,
you gotta define an UDS as the value you want (fluctuating velocities in this case) and then you can calculate the gradient using C_UDSI_G(c,t,i)[0] whereas i is the number of the UDS you define and [0] is in the x direction (1 and 2 for y and z direction respectively).

March 8, 2016, 14:53
#8
Member

Join Date: May 2013
Posts: 32
Rep Power: 6

I never tried a UDF and UDS before. Could you please give me some more help on this? I have added an image file of the equation that I am trying to define in Fluent.
Thank you,
Attached Images
 strain rate.JPG (36.5 KB, 50 views)

March 11, 2016, 10:02
#9
Senior Member

Join Date: May 2014
Posts: 271
Rep Power: 6
Quote:
 Originally Posted by maphd Bruno Machado, Thank you for your reply. I really appreciate your help. I never tried a UDF and UDS before. Could you please give me some more help on this? I have added an image file of the equation that I am trying to define in Fluent. Thank you,
I recommend you to have a read in the fluent manual, in the UDS (User Define Scalar) section. There you will understand how to setup a scalar in your case.

The macro C_UDSI_G(c,t,i)[0] is the derivative with respect of X, whilst C_UDSI_G(c,t,i)[1] is in the Y direction and C_UDSI_G(c,t,i)[2] is with respect of Z direction.
What you gotta do is to define a UDS (fluctuating velocity) and then using the macros previous mentioned, you can easily reproduce the equation you attached.