Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

Fluent UDF obtain derivative and material properties values

    • eric1234598765
      Subscriber

      Hi,

      I'm using Fluent 2020R2 to obtain laminar viscosity and velocity derivative via "C_MU_L(c,t)" and "C_DUDY(c,t)".

      The trouble UDF is tested in VOF model with single processor using SST-K-OMEGA, which is going to compute the viscous drag of the "interface" which Fluent can't handle.

      Here's UDF:

      ==================================================================

      #include "udf.h"

      DEFINE_ON_DEMAND(Viscous_Drag)

      {

          Domain *d = Get_Domain(1); /*Get the domain ID*/

          face_t f;

          cell_t c;

          /*Get the thread id of that surface*/

          Thread *t  = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */;

          Thread *t1 = Lookup_Thread(d,7); /* Interface_Fluid_porous2 */;

          real force;

          real avgf;

          int ii;

          if (!Data_Valid_P())

          {

          return;

          }

          force=0.0;

          avgf=0.0;

          ii=1;

          /* Loop over all cell*/

          begin_c_loop(c,t)

          {

              force  = force + C_MU_L(c,t);

          }

          end_c_loop(c,t)

          Message("Viscous drag is = %8.4f ", force );

      }

      =================================================================

      After debugging, I found that the Fluent would pop out "Received signal SIGSEGV." error and show the zero value when I using either "C_MU_L(c,t)" or "C_DUDY(c,t)" in the begin_c_loop, and with no problem when using other UDF cell macro such as C_T(c,t), C_K_L(c,t), and so on. However, laminar (molecular) viscosity was checked by xy-plot which is not zero.

      Obviously, the problem is the misusing of the C_MU_L(c,t) and C_DUDY(c,t), therefore, I looking forward to any help.

      Thanks!

    • eric1234598765
      Subscriber
      Update:
      Same error as stated when the VOF model is off.

    • Rob
      Ansys Employee
      Check if C_MU_L(c,t) needs a phase domain for VOF. I'm guessing, UDFs aren't one of my strong points.
    • eric1234598765
      Subscriber
      Hi I've solved the problem by pointing the face thread to the face centroid, which is
      Thread *t = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */
      Thread *t0 = t->t0; /* Access t0 (Pointer to the adjacent cells thread.) from t (face thread) */

      And using adjacent Cell Index in the f_loop , which is:
      c0 = F_C0(f,t);
      Now, the pointers I set are : t, t0, c0. Using c0 and t0 instead of c and t solve the problem in the loop. So the UDF is like:
      ==================================================
      DEFINE_ON_DEMAND(Viscous_Drag1)
      {
      Domain *d = Get_Domain(1); /*Get the domain ID*/
      face_t f; /*Index that identifies a wall face.*/
      cell_t c0; /*Cell index that identifies the cell next to the wall.*/

      /*Get the thread id of that surface*/
      Thread *t = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */
      Thread *t0 = t->t0; /* Access t0 (Pointer to the adjacent cells thread.) from t (face thread) */
      real viscosity;

      if (!Data_Valid_P())
      {
      return;
      }
      real NV_VEC (A); /*Area normal vector*/
      /* Loop over all surface faces*/
      begin_f_loop(f,t)
      {
      F_AREA(A,f,t); /*Get the area vector*/
      c0 = F_C0(f,t);
      viscosity += C_MU_EFF(c0,t0);
      }
      end_f_loop(f,t)
      }
      =========================================
      Best
Viewing 3 reply threads
  • You must be logged in to reply to this topic.