CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to calculate velocity at cell face? (https://www.cfd-online.com/Forums/fluent-udf/109005-how-calculate-velocity-cell-face.html)

 tjmartian November 6, 2012 23:55

How to calculate velocity at cell face?

Currently I am looping over all the cells in my 2-D geometry to find u and v at each cell; however, at the corners and boundaries where I am getting recirculation, the math isn't coming out correctly using the u and v values taken from Fluent. I would assume that the velocity at the centroid is just interpolated from the face velocities so I am trying to find a way to use the velocities at the faces instead; is there a way to do this? I tried writing this quick code to test this but I am getting a Fluent access error when I try to run it:

#include"udf.h"
#include"metric.h"
#include"stdio.h"
#include"math.h"
#include"stdlib.h"
#include"mem.h"

{

face_t f;

real cent[2];
double centr_x, centr_y;
double vel_x, vel_y;

{
begin_f_loop(f,t)
{
F_CENTROID(cent,f,t);

centr_x = cent[0];
centr_y = cent[1];
vel_x = F_U(f,t);
vel_y = F_U(f,t);

printf(
"%f, %f\n", vel_x, vel_y);
}
end_f_loop(f,t)
}
}

After reading some other threads I saw that this only works for boundaries so I may not be able to do it this way. Is there a way I can get this to work? If not are there any other macros that will help me do what I want? If not I may need to play around with the math and see if I can get it to work better instead. Thanks for your help.

 gearboy November 7, 2012 02:42

F_U, F_V are only valid for boundary.

For those face in the domain, you can use the averaged value of F_C0 and F_C1.

Quote:
 Originally Posted by tjmartian (Post 390715) Currently I am looping over all the cells in my 2-D geometry to find u and v at each cell; however, at the corners and boundaries where I am getting recirculation, the math isn't coming out correctly using the u and v values taken from Fluent. I would assume that the velocity at the centroid is just interpolated from the face velocities so I am trying to find a way to use the velocities at the faces instead; is there a way to do this? I tried writing this quick code to test this but I am getting a Fluent access error when I try to run it: #include"udf.h" #include"metric.h" #include"stdio.h" #include"math.h" #include"stdlib.h" #include"mem.h" DEFINE_ADJUST(velocity_profile_face,d) { Thread *t; face_t f; real cent[2]; double centr_x, centr_y; double vel_x, vel_y; thread_loop_f(t,d) { begin_f_loop(f,t) { F_CENTROID(cent,f,t); centr_x = cent[0]; centr_y = cent[1]; vel_x = F_U(f,t); vel_y = F_U(f,t); printf("%f, %f\n", vel_x, vel_y); } end_f_loop(f,t) } } After reading some other threads I saw that this only works for boundaries so I may not be able to do it this way. Is there a way I can get this to work? If not are there any other macros that will help me do what I want? If not I may need to play around with the math and see if I can get it to work better instead. Thanks for your help.

 tjmartian November 8, 2012 01:45

Thank you, I hadn't seen those macros before. I think I can get what I need from there.

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