
[Sponsors] 
April 20, 2010, 06:05 
access velocity on xyline in udf

#1 
New Member
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 8 
hi,
i have created a grid and set it up for a vof calculation and created a horizontal line in fluent with the surface/line option. now i want to access the yvelocity on the line in the flow field and calculate the mean value for setting my bc depending on the results. this is my code: #include "udf.h" DEFINE_PROFILE(settau,thread,i) { Domain *d; Thread *t; face_t f,v; real v_sum, v_mean_wall=0, v_mean_xy=0; int count, zone_id_wall=THREAD_ID(thread), zone_id_xy=14; //i know the id of the line //velocity at xy line d=Get_Domain(1); t=Lookup_Thread(d,zone_id_xy); v_sum=0; count=1; begin_f_loop(v,t) { v_sum+=F_V(v,t); count++; } end_f_loop(v,t) v_mean_xy=v_sum/count; printf("mean y velocity at xyline %i is: %g m/s with %d cells\n", zone_id_xy, v_mean_xy, count); //velocity at BC v_sum=0; count=1; begin_f_loop(f,thread) { v_sum+=F_V(f,thread); ++count; } end_f_loop(f,thread) v_mean_wall=v_sum/count; printf("mean y velocity at wall %i is: %g m/s with %d cells\n", zone_id_wall, v_mean_wall, count); //set bc depending on results if (v_mean_wall<=0 && v_mean_xy<=0) { begin_f_loop(f,thread) { F_PROFILE(f,thread,i)=0.06; } end_f_loop(f,thread) printf("velocity is negative. set tau to 0.06\n"); } else { begin_f_loop(f,thread) { F_PROFILE(f,thread,i)=0.06; } end_f_loop(f,thread) printf("velocity is positive. set tau to 0.06\n"); } } i get an access violation because of the F_V(,t) command. i assume i can not access the y velocity on a xyline like this with the face command. i searched the documentation, but i didn't found anything what kind of data type a line is and how i can access its values. maybe somebody knows? thanks a lot! 

April 20, 2010, 18:48 

#2 
New Member
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 8 
i found out that as far as i know it is not possible to access data with a face loop on a xy line like i tried to.
it seems that a line of interest has to be defined in the mesh/grid generator (for example gambit), so it is getting its own fixed id that you can see in the BC panel. with this id you are able to access the "line" in udf with lookup_thread. but it is not working if the bc on this created line is set to "interior". in that case i still get access error. 

April 21, 2010, 05:55 

#3 
Senior Member
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 9 
hello moe,
a possible workaround would be to use solve/execute command to calculate the average and write it to a file at any intervals (e.g. every timestep). Just record a macro with the appropriate steps: report/surface integrals blablabla.... Then read the current value within your udf from the file and update your bc. cheers 

April 21, 2010, 15:36 

#4 
New Member
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 8 
i have not tried the workaround, because it's not suitable in my case. but it might work.
after having a conversation with some experts i found out that it is not possible to acces velocity at interior faces. http://my.fit.edu/itresources/manual...udf/node91.htm for interior faces you can only get the massflow rate and the pressure. other variables have to be computed by the user himself. the other properties you only can get on boundary lines. closed 

April 22, 2010, 07:13 

#5 
New Member
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 8 
i found out that it is possible to get the velocities and other properties through the adjacent cells of the face. when the line is interior C0 and C1 exist, then the velocity can be accessed with F_C0(f,t)/F_C1(f,t) and THREAD_T0(t)/THREAD_T1(t).
you can calculate an average value on different ways by yourself. 

October 23, 2010, 05:11 
Hi.

#6 
New Member
Join Date: Aug 2010
Posts: 6
Rep Power: 7 
Hello.
I have a 2D (x,y) domain of size (0,0)(xmax,ymax) divided into a 50x50 grid. I want to find properties (e.g. yvelocity) of all cells at any given instant in the following manner. for (y=0,y=ymax,y++) { for(x=0,x=xmax,x++) { location[x][y]= ........ ? y_velocity[x][y]=........ ? } } It means that I fix y, then loop over all available xcells to store values. Then increase y and repeat the process for xcells. I need to store the values in arrays for further analysis or written to files. How do I add it to my UDF ? Thanx. NVD. 

Tags 
fluent, line, udf, velocity 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
DPM UDF particle position using the macro P_POS(p)[i]  dm2747  FLUENT  0  April 17, 2009 01:29 
Problem of compilation OF 14Allwmake command not found  erik_d  OpenFOAM Bugs  13  September 13, 2008 21:45 
GMSH and OpenFOAM  derath  OpenFOAM Mesh Utilities  44  September 4, 2008 05:09 
errors  Fahad  Main CFD Forum  0  March 23, 2004 14:20 
Problems of Duns Codes!  Martin J  Main CFD Forum  8  August 14, 2003 23:19 