Access_Violation Error due to DEFINE_ADJUST
I am trying to achieve single bubble growth from a uniformly heated surface by performing a transient solution. I patch a small bubble (r ~ 50 microns) at time t = 0. I use DEFINE_ADJUST macro and assign memory locations to compute my source/sink terms in vapor/liquid phase respectively. Apparently, this macro is causing an access_violation error. Here's the DEFINE_ADJUST part of the code:
Thread *t; /* t is a pointer array that identifies all mixture level threads in the domain */
Thread **pt; /* pt is a pointer array that identifies the phase-level threads */
real xc[ND_ND]; /* direction vector */
Thread *lt = THREAD_SUB_THREAD(t,liquidphaseindex);
/* Loop for specifying liquid volume fraction gradients, evaporation mass flux and boundary condition at L-V interface */
/* Memory variables to store local variables information */
C_UDMI(c,t,0) = 0.0; /* unsmeared local mass evaporation rate */
C_UDMI(c,t,1) = 0.0; /* local energy evaporation rate */
C_UDMI(c,t,2) = 0.0; /* evaporation mass flux */
C_UDMI(c,t,3) = 0.0; /* product of volume fraction and volume fraction gradient of liquid phase */
C_UDMI(c,t,4) = 0.0; /* normalization factor */
sum_vof_vofgmag += C_VOF(c,lt)*NV_MAG(C_VOF_G(c,lt))*C_VOLUME(c,t);
sum_vofgmag += NV_MAG(C_VOF_G(c,lt))*C_VOLUME(c,t);
normfactor = sum_vofgmag/sum_vof_vofgmag;
if(C_VOF(c,lt) != 1.0 && C_VOF(c,lt) != 0.0 && NV_MAG(C_VOF_G(c,lt)) != 0.0) /* liquid-vapor interface */
C_UDMI(c,t,2) = (2*evapcoeff/(2 - evapcoeff))*(hlv*hlv/(pow((2*pi*Rgasconst),0.5)))*(rhovap/(pow(Tsat,1.5)))*((C_T(c,t) - Tsat)/hlv);
C_UDMI(c,t,3) = C_VOF(c,lt)*NV_MAG(C_VOF_G(c,lt));
C_UDMI(c,t,4) = normfactor;
C_UDMI(c,t,0) = C_UDMI(c,t,4)*C_UDMI(c,t,2)*C_UDMI(c,t,3)*C_VOF(c, lt);
C_UDMI(c,t,1) = -C_UDMI(c,t,0)*hlv;
} /* fluid_thread loop ends here */
} /* multiphase loop ends here */
} /* define_adjust loop ends here */
The C_UDMI(c,t,0) acts as the mass source/sink term for liquid/vapor phase respectively. C_UDMI(c,t,1) acts as the energy source term. Any help will be deeply appreciated.
Forgetting to allocate 5 user defined memory zones before starting the iteration, would result in such an error.
I have allocated five memory zones. Are there any other reasons why this might happen?
At first glance, you're using an undocumented macro C_VOF_G, which I suspect is returning a gradient. If you follow the manual in section "Gradient (G) and Reconstruction Gradient (RG) Vector Macros" you will find that before you execute any gradient macros you have to tell the solver to keep that particular type of data.
If this is not the case, then I would suggest you to try to debug your udf. Here is a small example on how to do that: http://www.cfd-online.com/Wiki/Udf_debug
Thanks dmorian for your reply.
Should I go ahead and allocate memory for the gradient of VOF then?
|All times are GMT -4. The time now is 13:59.|