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

[UDF] Relative coordinates in logarithmic velocity profile

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2009, 12:31
Default [UDF] Relative coordinates in logarithmic velocity profile
  #1
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
Hello, I have a problem with the definition of a boundary condition with UDF to simulation of the wind in a terrain. I have to define a velocity inlet in a 3d domain; this condition is a logarithmic velocity profile. I can define the logarithmic velocity profile with UDF, like this:



#include "udf.h"

DEFINE_PROFILE(log_velocity,thread,index)
{
real x[ND_ND];
real z;
face_t f;

begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
z = x[2];
F_PROFILE(f,thread,index) = 3*log(z/0.01)/log(10/0.01);
}
end_f_loop(f,thread)
}


My domain is this:



I have to impose the logarithmic profile in the front face that is shown in figure.
My question is how I define in the UDF so that the velocity in bottom of the face is equal 0.
My problem is the coordinates that I use in UDF are absolute and I don’t know how to define relative coordinates, in order to the z in the equation that defines the velocity profile, is the height relatively to the bottom of the face and not the absolute height.

I would appreciate any suggestions.

Last edited by cfdworker; April 23, 2009 at 20:39.
cfdworker is offline   Reply With Quote

Old   April 21, 2009, 05:28
Default
  #2
New Member
 
VLKOH
Join Date: Mar 2009
Location: Malaysia
Posts: 20
Rep Power: 17
lalula2 is on a distinguished road
hi, i need help on creating UDF for logarithmic velocity profile for my final year project also. But i am not very familiar with c programming language...any good example for me to follow??
thanks
lalula2 is offline   Reply With Quote

Old   April 23, 2009, 11:53
Default
  #3
New Member
 
VLKOH
Join Date: Mar 2009
Location: Malaysia
Posts: 20
Rep Power: 17
lalula2 is on a distinguished road
Hi cfdworker....
since ur simulation problem is 3D, then how about the y vector??
and for the array part,shudnt it be 3D array??
Any pro or expert here mind to share their suggestion and opinion?
thanks.
lalula2 is offline   Reply With Quote

Old   April 23, 2009, 12:25
Default
  #4
New Member
 
Join Date: Apr 2009
Location: KA, Germany
Posts: 20
Rep Power: 17
Häwimeddel is on a distinguished road
I guess your boundary condition for the landscape ist WALL. To estimate the distace from any cell to the nearest WALL, you could maybe use C_WALL_DIST(c,t).
Häwimeddel is offline   Reply With Quote

Old   April 23, 2009, 17:20
Default
  #5
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
Hi, thanks for the reply. I tried to use the C_WALL_DIST(c,thread) macro like this:


#include "udf.h"

DEFINE_PROFILE(log_velocity,thread,index)
{
real z;
face_t f;
cell_t c;

begin_f_loop(f,thread)
{
z = C_WALL_DIST(c,thread);
F_PROFILE(f,thread,index) =3*log(z/0.01)/log((10)/0.01);
}
end_f_loop(f,thread)
}



But when i selected the udf in velocity inlet in boundary condition, fluent gave me this message:


Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()



I think the problem is that the boundary condition that I set is to a face and I use a macro for cells in the udf.

I don’t know how to use this macro for my situation. Can anyone help me with this issue ?

Thanks in advance

Last edited by cfdworker; April 23, 2009 at 17:44.
cfdworker is offline   Reply With Quote

Old   April 27, 2009, 10:25
Default
  #6
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
Someone can help me. Please I need someone who is patient to help me with this problem.

Thanks.
cfdworker is offline   Reply With Quote

Old   April 27, 2009, 20:38
Question
  #7
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
I tried to make another udf, as shown:


#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
cell_t c;

begin_c_loop(c, thread)
{
C_PROFILE(c, thread, position) = 3.*log(C_WALL_DIST(c,thread)/(0.01))/log(10./(0.01));
}
end_c_loop(c, thread)
}

But gave me the same error message.
I want to use the distance between the faces centroids that were determined by the F_CENTROID(f,thread) macro in the first udf and the terrain, in the face where I have to impose the velocity profile. But the only macro i know that give an distance is the C_WALL_DIST(c,thread), and this is applied to cells. I don't Know how to determine the distance for faces, for my problem.

Please, i beg for help.
cfdworker is offline   Reply With Quote

Old   April 29, 2009, 04:03
Default
  #8
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Hello,

try this one and let me know if it works. Having a look at the UDF-Manual section 3.2.5 might also help.

#include "udf.h"

DEFINE_PROFILE(log_velocity,thread,index)
{
real z;
face_t f;
cell_t c;
Thread *tc;

begin_f_loop(f,thread)
{
c = F_C0(f,thread);
tc = THREAD_T0(f,thread);
z = C_WALL_DIST(c,tc);
F_PROFILE(f,thread,index) =3*log(z/0.01)/log((10)/0.01);
}
end_f_loop(f,thread)
}

cheers
coglione is offline   Reply With Quote

Old   April 29, 2009, 09:14
Default
  #9
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
hello, thanks for the reply. I used your udf, but still gives the same error message, when I do init to start iterate.



Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()
cfdworker is offline   Reply With Quote

Old   April 29, 2009, 09:34
Default
  #10
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Hm,
seems like Fluent does not recognize C_WALL_DIST() at all. Is your case laminar or turbulent? It might be that C_WALL_DIST() is only available if a turbulence model is activated.

cheers
coglione is offline   Reply With Quote

Old   April 29, 2009, 09:59
Default
  #11
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
My case is turbulent. I think that the fluent recognizes the macro, i think that the problem is in using macro for cells in a boundary condition that is imposed in a face. I do not know if this is the problem. What do you think ?

Thanks
cfdworker is offline   Reply With Quote

Old   April 29, 2009, 10:38
Default
  #12
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
No, F_C0 and THREAD_T0 give you cell index and cell thread of the adjacent cell to each face at your boundary which is o.k. You can try the following:

type solve/set/expert in the text user interface of Fluent and enter yes if asked to keep temporary memory from being freed. Maybe a DEFINE_PROFILE macro for velocity i.e. applied for momentum equation does not has default access to C_WALL_DIST which is relevant for turbulence.

Hope this helps
coglione is offline   Reply With Quote

Old   April 29, 2009, 11:12
Default
  #13
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
I already did what you said, but even so it gives the same error message.

Thanks for the replys.
cfdworker is offline   Reply With Quote

Old   April 30, 2009, 09:41
Default
  #14
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Hi again,

it seems like you have to do some testing what the actual problem is.

If you replace C_WALL_DIST with for example C_CENTROID: does it work? This would indicate that C_WALL_DIST is to blame

If so, try to hook your DEFINE_PROFILE for one of the turbulence variables, e.g. k, and check whether it works then. If yes you could iterate one single iteration/timestep, store the cell wall distance in a UDM and proceed with your velocity-profile-udf using this values.

cheers
coglione is offline   Reply With Quote

Old   April 30, 2009, 15:54
Default
  #15
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
Hello. I did what you said. I replace C_WALL_DIST for C_CENTROID, but still gives the same error.
cfdworker is offline   Reply With Quote

Old   May 4, 2009, 03:34
Default
  #16
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Well, then something more fundamental is wrong with your udf. If you compile your udf, what does the log-file say? Everything ok or some warnings?

cheers
coglione is offline   Reply With Quote

Old   May 4, 2009, 10:11
Default
  #17
New Member
 
Join Date: Apr 2009
Posts: 14
Rep Power: 17
cfdworker is on a distinguished road
Hello.
I found a alternative way to define the velocity profile for my problem.
What I did was, first write out a profile file at the inlet boundary, then obtain a profile file, which contains vectores of x,y,z,cell wall distance and velocity magnitude, then I read the file with excel and replace the velocity magnitude by a function of cell wall distance (which is the logarithmic function for velocity profile). Then i save the altered data and read this back to fluent as profile. Finally, then I used these profiles as boundary conditions for the inlet.

Thanks for the replys.
cfdworker is offline   Reply With Quote

Old   May 14, 2009, 12:27
Default
  #18
New Member
 
VLKOH
Join Date: Mar 2009
Location: Malaysia
Posts: 20
Rep Power: 17
lalula2 is on a distinguished road
hi there, how to use fluent to read the altered data??
mind to share??
Thanks.
lalula2 is offline   Reply With Quote

Old   August 6, 2010, 13:11
Default
  #19
mrn
New Member
 
1236
Join Date: Mar 2010
Posts: 9
Rep Power: 16
mrn is on a distinguished road
dear cfdworker,
i have a problem same as your case and i have to define logarithmic velocity inlet at the beginning of cylindrical pipe.but unfortunately i have a error when i want to hook this udf and set as velocity inlet in boundary condition panel or it doesn't iterate( error is invalid number?!).please tell me how i can solve my problem.i have wrote the udf as below.velocity inlet is in y direction.

#include "udf.h"

DEFINE_PROFILE(inlet_y_velocity, thread, position)

{

real xc[ND_ND];

real ro,mu_t,visc_t,x,y,z,a,r,rw,utaw,rbi,yplus,b;

cell_t c;
face_t f;
ro = C_R(c,thread);
mu_t = C_MU_T(c,thread);
visc_t=mu_t/ro;

begin_f_loop(f, thread)

{

F_CENTROID(xc,f,thread);

x = xc[0];
y = xc[1];
z = xc[2];

rw=0.5;
utaw=0.0176;
r=sqrt(pow(x,2)+pow(z,2));
rbi=r/rw;
yplus=utaw*r/visc_t;

b=(1.5*yplus*(1+rbi))/(1+2*pow(rbi,2.));


F_PROFILE(f, thread, position) = utaw*(2.5*log(b)+5.5);

}

end_f_loop(f, thread)

}
mrn is offline   Reply With Quote

Old   August 8, 2014, 11:59
Default wind profile
  #20
New Member
 
Mahdi
Join Date: Nov 2012
Location: Malaysia
Posts: 27
Rep Power: 13
metmet is on a distinguished road
Dear friends
Would you mind if I remind this thread after along time?
Actually I want to simulate a tower with 30 levels in a 3D domain created by ICEM CFD. My objective is to simulate airflow around the tower and also investigate about the flow inside apartments in several levels which their windows are open in windward direction so I concern about wind profile which gives different value of velocity in different levels (heights). I have found that Log law wind profile will be used in this study but I'm very beginner in UDF so would you please guide me how come I can write a correct UDF suitable in my case? I will use K-Epsilon RNG and K-Omega turbulence models in my study and inlet is velocity inlet and outlet will be pressure outlet. the dimensions of domain is 700m (X), 350m (Y) and 280m (Z) which Z is height direction in this case. and apartments will be in 1m, 6m, 10m, 25m and 50 m of height.
Would you please guide me how I can solve my problem?
metmet 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
3D UDF Paraboilc Velocity Profile (Can't Maintain) Sing FLUENT 12 August 7, 2017 06:25
[boundary condition] logarithmic velocity profile cfdworker FLUENT 2 April 17, 2009 23:36
maintaining a logarithmic velocity distribution Morten Andersen CFX 1 January 8, 2007 11:37
Variables Definition in CFX Solver 5.6 R P CFX 2 October 26, 2004 02:13
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


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