|
[Sponsors] |
May 8, 2013, 23:23 |
Access_Violation Error due to DEFINE_ADJUST
|
#1 |
Member
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15 |
Folks,
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: DEFINE_ADJUST(massenergy_transfer,mixture_domain) { 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 */ cell_t c; real normfactor=0; real sum_vof_vofgmag=0; real sum_vofgmag=0; real ystar; Thread *tf; face_t f; int liquidphaseindex=0; real xc[ND_ND]; /* direction vector */ mp_thread_loop_c(t,mixture_domain,pt) { if (FLUID_THREAD_P(t)) { Thread *lt = THREAD_SUB_THREAD(t,liquidphaseindex); /* Loop for specifying liquid volume fraction gradients, evaporation mass flux and boundary condition at L-V interface */ begin_c_loop_all (c,t) { /* 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; } } end_c_loop_all (c,t) } /* 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. |
|
May 9, 2013, 15:15 |
|
#2 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Forgetting to allocate 5 user defined memory zones before starting the iteration, would result in such an error.
|
|
May 9, 2013, 22:31 |
|
#3 |
Member
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15 |
I have allocated five memory zones. Are there any other reasons why this might happen?
|
|
May 10, 2013, 04:26 |
|
#4 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
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 |
|
May 10, 2013, 15:05 |
|
#5 |
Member
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15 |
Thanks dmorian for your reply.
Should I go ahead and allocate memory for the gradient of VOF then? |
|
November 22, 2018, 07:17 |
|
#6 |
Senior Member
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10 |
Hi,
May be you have to enter "YES" when prompted for the following question: Keep temporary solver memory from being freed? [yes] This question appears in the text user interface of Fluent under solve/set/expert And I have a query for you! Could you get success in modeling evaporation? If yes, please let me know. Thanks in advance! vidyadhar |
|
Tags |
access violation error, define_adjust, udf and programming |
|
|