CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for source term: ACCESS_VIOLATION (http://www.cfd-online.com/Forums/fluent-udf/83690-udf-source-term-access_violation.html)

xiaoyoyo January 7, 2011 15:05

UDF for source term: ACCESS_VIOLATION
 
Hi all,
I am writing UDFs for Antal wall lubrication force and turbulent dispersion force as source of x_momentum equation (as well as y and z direction). They can be compiled correctly, while when i start the calculation, Fluent gave me the error message:FLUENT received fatal signal (ACCESS_VIOLATION).

I also tried intepreted them, and I got the same error.

Can anybody help me to check my code? Thank you in advance!

Below is my UDF for x_momentum equation

#include
"udf.h"
#define dia32 0.0025 /* bubble size*/
#define CT 0.1 /* coefficient*/
#define CW1 0.01 /* coefficient*/
#define CW2 0.05 /* coefficient*/
DEFINE_SOURCE(xmom_source,cell,thread,dS,eqn)
{
real x_vel_g, x_vel_l, y_vel_g, y_vel_l, z_vel_g, z_vel_l, slip_x, slip_y, slip_z,
abs_v,rho_g, rho_l, reyb, void_g, k_l, g_alpha, CWL, dis, ratio_d, vector_w, U_ax,
source_WLx, source_TDx, source_x;
Thread *thread_g, *thread_l;
thread_l = THREAD_SUB_THREAD(thread, 0);
/* primary pahse: liquid*/
thread_g = THREAD_SUB_THREAD(thread, 1);/* Secondary phase: gas*/
/* find phase velocities and properties*/
x_vel_g = C_U(cell, thread_g);
y_vel_g = C_V(cell, thread_g);
z_vel_g = C_W(cell, thread_g);
x_vel_l = C_U(cell, thread_l);
y_vel_l = C_V(cell, thread_l);
z_vel_l = C_W(cell, thread_l);
rho_g = C_R(cell, thread_g);
rho_l = C_R(cell, thread_l);
slip_x = x_vel_g - x_vel_l;
slip_y = y_vel_g - y_vel_l;
slip_z = z_vel_g - z_vel_l;
void_g = C_VOF(cell, thread_g);
/* gas vol fraction */
dis = C_WALL_DIST(cell,thread); /* distance to wall*/
k_l = C_K(cell,thread_l); /*liquid turbulent kinetic engergy*/
/* U_ax = slip_x-(slip_x*vector_w)*vector_w; */
/* compute CWL */
CWL = MAX(0,CW1/dia32+CW2/dis);
/* compute ratio_d */
ratio_d = dis/dia32;
/*compute wall lubrication force*/
if (ratio_d <= 5.0)
{
source_WLx = -1*CWL*void_g*rho_l*(slip_x)*(slip_x);
}
else
{
source_WLx = 0;
}
/*compute turbulent dispersion force*/
if (NULL != THREAD_STORAGE(thread,SV_VOF_G))
{
g_alpha = C_VOF_G(cell,thread_g)[0]; /*gradient of air volume fraction*/
}
else
{
g_alpha = 0;
}
source_TDx = -1*CT*rho_l*k_l*g_alpha;
source_x = source_WLx + source_TDx;
dS[eqn] = 0;
return source_x;
}


All times are GMT -4. The time now is 23:44.