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

access velocity on xy-line in udf

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   April 20, 2010, 06:05
Default access velocity on xy-line in udf
  #1
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 7
moe is on a distinguished road
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 y-velocity 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 xy-line %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 xy-line 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!
moe is offline   Reply With Quote

Old   April 20, 2010, 18:48
Default
  #2
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 7
moe is on a distinguished road
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.
moe is offline   Reply With Quote

Old   April 21, 2010, 05:55
Default
  #3
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 8
coglione is on a distinguished road
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
coglione is offline   Reply With Quote

Old   April 21, 2010, 15:36
Default
  #4
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 7
moe is on a distinguished road
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
moe is offline   Reply With Quote

Old   April 22, 2010, 07:13
Default
  #5
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 7
moe is on a distinguished road
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.
moe is offline   Reply With Quote

Old   October 23, 2010, 05:11
Default Hi.
  #6
New Member
 
Join Date: Aug 2010
Posts: 6
Rep Power: 6
beezee99 is on a distinguished road
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. y-velocity) 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 x-cells to store values. Then increase y and repeat the process for x-cells. 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.
beezee99 is offline   Reply With Quote

Reply

Tags
fluent, line, udf, velocity

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 22:11.