We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Segmentation Fault : udf for scalar

TAGGED: ,

    • desouzadacosta
      Subscriber

      Hello,
      I am getting a segmentation fault error in fluent. After trying to use
      the following udf :

      #include "udf.h"
      #define tau_s 250.0
      #define alpha 3.63e-7
      #define beta 2.416
      #define cc 0.785
      DEFINE_SOURCE(hsource, c, t, dS, eqn)
      {
      real source;
      real tau_xx, tau_yy, tau_zz, h_tau, tau_vm, h_l;

      h_l = C_UDSI(c,t,0);
      tau_xx = -2.*C_MU_L(c,t)*C_DUDX(c,t);
      tau_yy = -2.*C_MU_L(c,t)*C_DVDY(c,t);
      tau_zz = -2.*C_MU_L(c,t)*C_DWDZ(c,t);
      h_tau = 0.5*( pow(tau_xx + tau_yy + tau_zz,2) - (pow(tau_xx,2) + pow(tau_yy,2) + pow(tau_zz,2)));
      tau_vm = sqrt(-1*h_tau);

      if (tau_vm <= tau_s)
      {
      source = 0;
      dS[eqn] = 0;
      }
      else
      {
      source = pow(cc,1./beta)* pow(tau_vm, alpha/beta)*(1 - h_l) ;
      dS[eqn] = -pow(cc,1./beta)* pow(tau_vm, alpha/beta);
      }
      return source;
      }

      Below is the reported error.log :

      Node 1 Fatal signal raised sig = Segmentation fault
      25179dd0 CX_Primitive_Error
      66640cc0 seh_filter_exe
      251eb630 logical_right_shift
      5631f6a0 _C_specific_handler
      68a11fb0 _chkstk
      689c1020 RtlRaiseException
      68a10bd0 KiUserExceptionDispatcher
      610e0000 Ordinal0
      241b4e30 user_sources
      2445d560 UDS_Derivatives
      2445d560 UDS_Derivatives
      22f81570 Models_Send_update_solve
      23648590 solver_update
      23644a30 Flow_Iterate
      22e58ae0 Set_panfs_optimum_file_layout
      251d5e60 eval
      22f5c7b0 PRF_Command_Start
      22f5eed0 PRF_Node_repl
      22f6a910 Delay_Error
      251eb630 logical_right_shift
      67d37020 BaseThreadInitThunk
      689c2630 RtlUserThreadStart

      Error [node 1] [time 7/26/24 16:32:6] Abnormal Exit!
      Node 1 Fatal signal raised sig = Segmentation fault
      19559dd0 CX_Primitive_Error
      bd930cc0 seh_filter_exe
      195cb630 logical_right_shift
      ac30f6a0 _C_specific_handler
      bfa11fb0 _chkstk
      bf9c1020 RtlRaiseException
      bfa10bd0 KiUserExceptionDispatcher
      433c0000 Ordinal0
      18594e30 user_sources
      1883d560 UDS_Derivatives
      1883d560 UDS_Derivatives
      17361570 Models_Send_update_solve
      17a28590 solver_update
      17a24a30 Flow_Iterate
      17238ae0 Set_panfs_optimum_file_layout
      195b5e60 eval
      1733c7b0 PRF_Command_Start
      1733eed0 PRF_Node_repl
      1734a910 Delay_Error
      195cb630 logical_right_shift
      be3c7020 BaseThreadInitThunk
      bf9c2630 RtlUserThreadStart

      Error [node 1] [time 7/30/24 18:27:45] Abnormal Exit!

      Anyone has a clue what is happening? It is compiling and loading fine.
      Thanks.

    • Rob
      Forum Moderator

      You may need to include mem.h  https://ansyshelp.ansys.com/public/account/secured?returnurl=/Views/Secured/corp/v242/en/flu_udf/flu_udf_DataAccessMacros.html?q=C_DUDX  Also check the scalars are set and have a value. 

    • desouzadacosta
      Subscriber

      Hi Rob,

      It is still crashing with include "mem.h". 

      Should I allocate UDMs for C_MU_L(c,t), C_DUDX(c,t), C_DVDY(c,t), C_DWDZ ?
      Thanks.

    • Rob
      Forum Moderator

      You shouldn't need UDMs, but double check those macros are available - you may need to tell Fluent to retain data as some of the gradients are not held in RAM by default. There's a TUI command in the manual regarding that. 

    • desouzadacosta
      Subscriber

      Tried : /solve/set/expert
      Keep temporary solver memory for being freed? [no] yes

      No success.

    • Rob
      Forum Moderator

      Is h_tau always less than zero? Would using absolute(h_tau) be safer than SQRT(-1.x.h_tau)?

      You need to check though the code and make sure everything has a sensible value. 

Viewing 5 reply threads
  • The topic ‘Segmentation Fault : udf for scalar’ is closed to new replies.