Hello,

I am trying to create a UDF which can solve an additional equation for a UDS. It gives segmentation error no matter what changes I do to the code. I have compiled and defined the UDFs correctly. (No problem there).

The UDF Code:

#include "udf.h"

#include "header.h"

DEFINE_ADJUST(normalization_coefficient,d)

{

real Normalization_coeff;

real sum_mod_grad_alpha = 0;

real sum_mod_alpha_l_grad_alpha = 0;

#if !RP_HOST

int zone_ID = 2;

Thread *tc = Lookup_Thread(d,zone_ID);

cell_t c;

Domain *dom;

begin_c_loop_int(c,tc)

{

sum_mod_grad_alpha += (NV_MAG(C_VOF_G(c,tc))*C_VOLUME(c,tc));

sum_mod_alpha_l_grad_alpha += (0.5*NV_MAG(C_VOF_G(c,tc))*C_VOLUME(c,tc));

}

end_c_loop_int(c,tc)

#endif /* !RP_HOST */

sum_mod_grad_alpha = PRF_GRSUM1(sum_mod_grad_alpha);

sum_mod_alpha_l_grad_alpha = PRF_GRSUM1(sum_mod_alpha_l_grad_alpha);

node_to_host_real_2(sum_mod_grad_alpha, sum_mod_alpha_l_grad_alpha);

#if !RP_NODE

Normalization_coeff = sum_mod_grad_alpha/sum_mod_alpha_l_grad_alpha;

#endif/* RP_NODE */

host_to_node_real_1(Normalization_coeff);

#if !RP_HOST

begin_c_loop_int(c, tc)

{

C_UDMI(c, tc, 0) = Normalization_coeff;

}

end_c_loop_int(c, tc)

#endif /* !RP_HOST */

}

DEFINE_SOURCE(phi_source,c,t,dS,eqn)

{

#if !RP_HOST

face_t f;

real con;

real s;

real kinetic_mobility, Normalization_coeff;

Normalization_coeff = C_UDMI(c,t,0);

kinetic_mobility = (2.*SIGMA /(2.-SIGMA))*(sqrt(MOL_MASS/(2.*PI*R*T_SAT)))*RHO_V*H_LV / T_SAT;

con = Normalization_coeff*H_LV*kinetic_mobility;

if PRINCIPAL_FACE_P(f,t)

{

return 0;

}

else

{

s = con*(NV_MAG(C_VOF_G(c,t)))*C_VOF(c,t)*(C_T(c,t)-T_SAT)-C_UDSI(c,t,0);

dS[eqn] = -1;

return s;

}

#endif

}

The Error:

Node 6: Process 5984: Received signal SIGSEGV.