CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Access_Violation Error due to DEFINE_ADJUST

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By shashank312
  • 1 Post By dmoroian

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 8, 2013, 22:23
Default Access_Violation Error due to DEFINE_ADJUST
  #1
Member
 
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15
shashank312 is on a distinguished road
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.
Geng Fu likes this.
shashank312 is offline   Reply With Quote

Old   May 9, 2013, 14:15
Default
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Forgetting to allocate 5 user defined memory zones before starting the iteration, would result in such an error.
dmoroian is offline   Reply With Quote

Old   May 9, 2013, 21:31
Default
  #3
Member
 
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15
shashank312 is on a distinguished road
I have allocated five memory zones. Are there any other reasons why this might happen?
shashank312 is offline   Reply With Quote

Old   May 10, 2013, 03:26
Default
  #4
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
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
Geng Fu likes this.
dmoroian is offline   Reply With Quote

Old   May 10, 2013, 14:05
Default
  #5
Member
 
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15
shashank312 is on a distinguished road
Thanks dmorian for your reply.

Should I go ahead and allocate memory for the gradient of VOF then?
shashank312 is offline   Reply With Quote

Old   November 22, 2018, 06:17
Default
  #6
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 9
vidyadhar is on a distinguished road
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
vidyadhar is offline   Reply With Quote

Reply

Tags
access violation error, define_adjust, udf and programming


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:42.