|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
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. |
|
|
|
|
|
|
|
|
#2 |
|
New Member
VLKOH
Join Date: Mar 2009
Location: Malaysia
Posts: 20
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#3 |
|
New Member
VLKOH
Join Date: Mar 2009
Location: Malaysia
Posts: 20
Rep Power: 6 ![]() |
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. |
|
|
|
|
|
|
|
|
#4 |
|
New Member
Join Date: Apr 2009
Location: KA, Germany
Posts: 20
Rep Power: 6 ![]() |
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).
|
|
|
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
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. |
|
|
|
|
|
|
|
|
#6 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
Someone can help me. Please I need someone who is patient to help me with this problem.
Thanks. |
|
|
|
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
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.
|
|
|
|
|
|
|
|
|
#8 |
|
Senior Member
Max
Join Date: Mar 2009
Posts: 127
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#9 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
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: () |
|
|
|
|
|
|
|
|
#10 |
|
Senior Member
Max
Join Date: Mar 2009
Posts: 127
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#11 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#12 |
|
Senior Member
Max
Join Date: Mar 2009
Posts: 127
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#13 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
I already did what you said, but even so it gives the same error message.
Thanks for the replys. |
|
|
|
|
|
|
|
|
#14 |
|
Senior Member
Max
Join Date: Mar 2009
Posts: 127
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#15 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
Hello. I did what you said. I replace C_WALL_DIST for C_CENTROID, but still gives the same error.
|
|
|
|
|
|
|
|
|
#16 |
|
Senior Member
Max
Join Date: Mar 2009
Posts: 127
Rep Power: 6 ![]() |
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 |
|
|
|
|
|
|
|
|
#17 |
|
New Member
Join Date: Apr 2009
Posts: 14
Rep Power: 6 ![]() |
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. |
|
|
|
|
|
|
|
|
#18 |
|
New Member
VLKOH
Join Date: Mar 2009
Location: Malaysia
Posts: 20
Rep Power: 6 ![]() |
hi there, how to use fluent to read the altered data??
mind to share?? Thanks. |
|
|
|
|
|
|
|
|
#19 |
|
New Member
1236
Join Date: Mar 2010
Posts: 9
Rep Power: 5 ![]() |
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) } |
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 3D UDF Paraboilc Velocity Profile (Can't Maintain) | Sing | FLUENT | 7 | September 1, 2011 01:38 |
| [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 |