udf velocity profile
hi I am trying to write a udf function that use the index number in order to put a value from array. I wrote the following function that isn't working
Code:
#include"udf.h" for example the first y , index=1 so u=A[1]=8; thanks for the help |
Are you sure that the range of c0 is in [0, 250] and at least one of these values are in [0,7] ? By the way, c language is zero-based so that A[0] = 8 and A[1] = 7.
|
yes
at my grid the velocity inlet border is the line x=0, -0.01<y<0.01 and I have 251 points on the line
|
Try this:
#include"udf.h" DEFINE_PROFILE(unsteady_velocity, thread, position) { real x[ND_ND]; /* this will hold the position vector */ real y;real A[251]={8,7,6,5,4,3,2,1}; real t = CURRENT_TIME; face_t f; int ind; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); c0 = F_C0(f,thread); y = 250*(x[1]*50+0.5); ind = (int) (y+0.5); F_PROFILE(f, thread, position) =A[ind]; } end_f_loop(f, thread) } |
...
my problem is that my grid is note uniform, there is a why to know the index from the grid?
thanks for the help |
It is easy to hard-coded your udf file. Print the value of c0. If the value of c0 is contiguous then shift the value so that c0 is in the range [0,250]. Or
#include"udf.h" DEFINE_PROFILE(unsteady_velocity, thread, position) { real x[ND_ND]; /* this will hold the position vector */ real y;real A[251]={8,7,6,5,4,3,2,1}; real t = CURRENT_TIME; face_t f; int ind=0; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); c0 = F_C0(f,thread); F_PROFILE(f, thread, position) =A[ind++]; } end_f_loop(f, thread) } if the values of array A is assigned according to its appearance in the thread loop. |
when i wrote the code
it was written to me the following message will running :
Divergence detected in AMG solver: x-momentum thanks for the help |
All times are GMT -4. The time now is 00:18. |