CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF_velocity profile (

Roby_1986 February 15, 2013 08:30

UDF_velocity profile
1 Attachment(s)
Hi everybody,
I'm studying, with Fluent, the model shown in the attached image.
I've to impose a loarithmic velocity profile at the upwind boundary, that is:
where: Uo= 1,068 m/s
ho=o,005 m
k=0,41 (-)

The questions are two:

1)In setting the boundary conditions, I've to select, for the upwind face, a UDF velocity profil (created on the basis of the formula: U(h)=Uo/k*ln(h/ho)). While, for the other three faces, which are also inlet faces, I have to select the same UDF or to create other ones?

2)I've imposted a possible code for UDF, that is:

#include "udf.h"

#DEFINE Uo 1,068 //unit m/s
#DEFINE k 0,41
#DEFINE ho 0,005 //unit m

real x[ND_ND];
real y;
face_t f;

y = x[1];
F_PROFILE(f,thread,index) = Uo/k*log(y/ho);

Is it correct in your opinion?
I've never programmed in C language, so I don't know how to crate a UDF file, for loading it in FLUENT. Someone could please tell me how to do this?
Or, eventually, could I copy the code directly within command lines of fluent?


flotus1 February 15, 2013 09:53

First of all, you should use "." instead of "," as a decimal separator.

Yes, according to your sketch, you could use the same UDF for inlet, side walls and top walls. But it depends on the type of boundary conditions you want to use.
Velocity inlet at the inlet face is certainly a straightforward choice.
At the side walls, i would either use a symmetry boundary condition or a moving wall with the velocity profile from the UDF.
Same for the top wall, the choice between moving wall and symmetry bc is up to you.

How to get the UDF into fluent? Refer to the UDF manual :rolleyes:
The quick path: define -> user defined -> functions -> interpret or compile.

Roby_1986 February 15, 2013 10:34

Dear Flotus,
Thanks for the answer.
So, in your opinion I couldn't set 4 faces of the parallelepiped (except the basis) as velocity inlet, defining the same UDF for all?

I can't understand what you mean with setting symmetry boundary at the other faces; I should not have a symmetry with respect to anything?

As regard the moving walls, for the top face probably I would not have problems, becouse I should calculate the value of U at the max height (through the formula:U(h)=Uo/k*ln(h/ho)) and set up the obtained value in the settings of Moving Wall(Motion/Speed...).

But, with reference to right and left faces, I can't set a velocity profile for a moving wall, but just a value of speed. So, what do you mean?

Finally, do you think that different Boundary Condition would affect considerably the results?

Thanks a lot.

flotus1 February 15, 2013 10:54

My bad. I thought using UDFs for the velocity of moving walls was possible. Apparently, it isnt.

The problem with inlet BCs at the side walls is that the flow should be perpendicular to the face. In your case, the velocity is tangential to the surface.
A symmetry boundary condition (zero shear stress) is the usual way to model such a boundary.

The influence of the type of boundary condition (lets only discuss the top wall, because only here you are free to choose) depends on your setup.
If the top wall is "far" away from the obstacle and the flow is dominated by inertial forces, then the difference between the two BCs (symmetry, moving wall) will vanish.

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