CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Why my UDF return Zero? (https://www.cfd-online.com/Forums/fluent/158514-why-my-udf-return-zero.html)

siamak1438 August 27, 2015 04:40

Why my UDF return Zero?
 
Hello Friends,
I am going to calculate the following expression in FLUENT to plot the vorticity in my 2D model.

D=(du/dx+dv/dy)^2-4(du/dx*dv/dy-du/dy*dv/dx)
I write the following UDF:

DEFINE_ON_DEMAND(vorticity)

{
Domain *domain;
cell_t c;
Thread *t;
domain=Get_Domain(1);
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = pow((C_DUDX(c,t)+C_DVDY(c,t)),2)+4*(C_DUDX(c,t)*C_ DVDY(c,t)-C_DUDY(c,t)*C_DVDX(c,t));
}
end_c_loop (c,t)
}

Message("Done!");
}

But when I run the execution on demand, it returns zero, that means this code is not working?
I change the formula and write C_UDMI(c,t,0) = C_DUDX(c,t) and again it returns zero. Why velocity derivatives are not working? :(:confused::o
Thank you in advance for your assistance
Siamak

Bruno Machado August 27, 2015 06:16

Add this line before your message and compute manually the values to make sure you are reading them correctly:

if((c%10000) == 0)
Message("DUDX %f, DVDY %f, DUDY%f, DVDX %f\n", C_DUDX(c,t), C_DVDY(c,t), C_DUDY(c,t), C_DVDX(c,t));


All times are GMT -4. The time now is 13:53.