CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to write UDF programme inside FLUENT? (http://www.cfd-online.com/Forums/fluent-udf/63019-how-write-udf-programme-inside-fluent.html)

 coolyihao March 26, 2009 00:54

How to write an UDF programming inside FLUENT?

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

 Rami March 26, 2009 06:19

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.

 coolyihao March 26, 2009 06:49

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

 Drew March 28, 2009 21:12

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.

 zjbwow April 1, 2009 02:07

Quote:
 Originally Posted by Drew (Post 211162) 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~

 maphd March 8, 2016 13:24

UDF for derivatives if fluctuating velocities

Hello,

Does anyone know how to calculate 1st derivatives (partial derivative) of the fluctuating velocities in UDF? Appreciate any help.

Thanks,

 Bruno Machado March 8, 2016 14:23

Quote:
 Originally Posted by maphd (Post 588691) 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).

 maphd March 8, 2016 14:53

1 Attachment(s)

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,

 Bruno Machado March 11, 2016 10:02

Quote:
 Originally Posted by maphd (Post 588704) 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.

 mmunige June 5, 2016 21:08

nested if statement in udf

Respected members

I am using udf for defining transient temperature at inlet boundary of my model in fluent. I am writing nested if statement, but model keeps on using the same equation after 180 seconds, and does not move to the next if else statement. My udf is as follows:

#include"udf.h"

{

face_t f;

{

real t = RP_Get_Real("flow-time");

if ( t <= 100.0 )

else if (100.0 < t <= 180.0 )

else if (180.0 < t <= 200.0 )

else if (200.0 < t <= 400.0 )