-
-
December 30, 2025 at 5:38 pm
anthony.bowers
SubscriberHello,Â
I recently upgraded fluent from R22 to R25 and my UDF (see below) continously crashes when I try to run it on the updated R25 Fluent? Does anyone know how to access gradients with R25?Âreal hL ;DEFINE_ADJUST(store_gradient, domain)  {  Thread *t;  Thread **pt;  cell_t c;  real HL = 0.0;  real Vol = 0.0;  Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);    /* IMPORTANT: Ensure temporary solver memory is retained:      /solve/set/expert -> Keep temporary solver memory from being freed? yes      See Ansys Knowledge base reference. */  Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);  //allocate storage for scalar reconstructed and derivative.  Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);  Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);  mp_thread_loop_c (t,domain,pt)  /*You can use FLUID_THREAD_P to check whether a cell thread is a fluid thread. The macro is passed  a cell thread pointer t, and returns 1 (or TRUE) if the thread that is passed is a fluid thread, and 0  (or FALSE) if it is not */  if (FLUID_THREAD_P(t))  {    Thread *ppt = pt[P_PHASE];    int zone_ID = THREAD_ID(ppt);    if (zone_ID ==210)    {      begin_c_loop (c,t)      {        C_UDMI(c,t,0) = -C_VOF_G(c,ppt)[0];        C_UDMI(c,t,1) = -C_VOF_G(c,ppt)[1];        C_UDMI(c,t,2) = -C_VOF_G(c,ppt)[2];        HL += (1-C_VOF(c,ppt))*C_VOLUME(c,t);        Vol +=C_VOLUME(c,t);        C_UDMI(c,t,30)=(1-C_VOF(c,ppt))/porosity;        C_UDMI(c,t,31)=HL/(Vol*porosity);      }      end_c_loop (c,t)    }}  Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);  Vol= PRF_GRSUM1(Vol);  HL = PRF_GRSUM1(HL);  hL = HL/(Vol);} -
January 2, 2026 at 1:02 pm
Rob
Forum ModeratorIt's probably a good idea to check the  Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL) and other macros are valid. If they're not in the manual they can (seemingly) randomly change between versions as data storage functions are altered.Â
-
January 2, 2026 at 1:05 pm
Mark O
Ansys EmployeeThe code may have changed slightly. The latest version of calc_vof_grad is in the customiozation manual, Example 3 for DEFINE_ADJUST at
https://ansyshelp.ansys.com/public/account/secured?returnurl=//Views/Secured/corp/v252/en/flu_udf/flu_udf_GeneralSolverDEFINE.html%23flu_udf_sec_define_adjust
-
Viewing 2 reply threads
- You must be logged in to reply to this topic.
Innovation Space
Trending discussions
Top Contributors
-
4763
-
1565
-
1386
-
1242
-
1021
Top Rated Tags
© 2026 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.