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

access velocity on xy-line in udf

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By moe

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 20, 2010, 07:05
Default access velocity on xy-line in udf
  #1
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 17
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, 19:48
Default
  #2
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 17
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, 06:55
Default
  #3
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
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, 16:36
Default
  #4
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 17
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, 08:13
Default
  #5
moe
New Member
 
harry
Join Date: Sep 2009
Posts: 5
Rep Power: 17
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.
Kuljeet likes this.
moe is offline   Reply With Quote

Old   October 23, 2010, 06:11
Default Hi.
  #6
New Member
 
Join Date: Aug 2010
Posts: 6
Rep Power: 16
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

Old   February 11, 2022, 05:03
Default
  #7
New Member
 
Nagula Venkata Anirudh
Join Date: Feb 2022
Posts: 1
Rep Power: 0
Anirudh616 is on a distinguished road
Isn't velocity a cell property? Try using C loop instead of F loop
Anirudh616 is offline   Reply With Quote

Old   June 6, 2023, 12:19
Default accessing line properties
  #8
New Member
 
Kuljeet Singh
Join Date: Aug 2022
Posts: 20
Rep Power: 4
Kuljeet is on a distinguished road
One can use if statement using cell centroid as condition to make a line within begin c loop. I am assuming you know dimension and mesh details.
-K
Kuljeet is offline   Reply With Quote

Reply

Tags
fluent, line, udf, velocity


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
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 02:29
Problem of compilation OF 14Allwmake command not found erik_d OpenFOAM Bugs 13 September 13, 2008 22:45
[Gmsh] GMSH and OpenFOAM derath OpenFOAM Meshing & Mesh Conversion 44 September 4, 2008 06:09
errors Fahad Main CFD Forum 0 March 23, 2004 14:20
Problems of Duns Codes! Martin J Main CFD Forum 8 August 15, 2003 00:19


All times are GMT -4. The time now is 12:56.