Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Trial start of UDF for getting yplus at all cells

    • thamilmani
      Subscriber
      #include "udf.h"



      real get_yplus(cell_t c, Thread* t, Domain* domain)
      {
          // Declaration
          real result, cell_x_value, face_x_value, shear;
          real cell_centroid[ND_ND];
          real NV_VEC(face_centroid);
          face_t f;

       

          shear = 10;
          C_CENTROID(cell_centroid, c, t);
          cell_x_value = cell_centroid[0];

       

          thread_loop_f(t, domain)
          {
              begin_f_loop(f, t)
              {
                  if ((BOUNDARY_FACE_THREAD_P(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))
                  {
                      F_CENTROID(face_centroid, f, t);
                      face_x_value = face_centroid[0];
                      if (cell_x_value == face_x_value)
                      {
                          shear = 1;
                      }
                  }
              }
              end_f_loop(f, t)
          }

       

          return shear;
      }



      DEFINE_ADJUST(yplus, domain)
      {
          Thread* t;
          cell_t c;
          face_t f;

       

          /* Fill UDS with the variable. */
          thread_loop_c(t, domain)
          {
              begin_c_loop(c, t)
              {
                  C_UDSI(c, t, 0) = get_yplus(c, t, domain);
              }
              end_c_loop(c, t)
          }

       

          thread_loop_f(t, domain)
          {
              if (THREAD_STORAGE(t, SV_UDS_I(0)) != NULL)
              {
                  begin_f_loop(f, t)
                  {
                      if (BOUNDARY_FACE_THREAD_P(t))
                      {
                          F_UDSI(f, t, 0) = 0;
                      }
                      else
                      {
                          F_UDSI(f, t, 0) = ((get_yplus(F_C0(f, t), THREAD_T0(t), domain) + get_yplus(F_C1(f, t), THREAD_T1(t), domain)) / 2);
                      }
                  }
                  end_f_loop(f, t)
              }
          }
      }
       
      This UDF returns 10 only at all cell centres that is the internal face thread loop did not matched for any cell. Can anyone point what could be the logical flaw in the get_yplus function.
      This is a 2D axisymmetric pipe, with a constant heat flux at the wall.
    • Rob
      Forum Moderator

      You may find some hints here   https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v242/en/flu_udf/flu_udf_ModelSpecificDEFINE.html%23flu_udf_sec_define_wall_functions     You may find y+ is only defined in the near wall cell, so also have a look at the adjacent cell/thread section of the manual. 

Viewing 1 reply thread
  • You must be logged in to reply to this topic.