Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

fluent face loop

    • mimimiming
      Subscriber

      Hi all. I try to count the number of faces with a face loop.   However, the actual number of faces and the number of faces counted by the face loop are different.


      #include "udf.h"


      real face;


      DEFINE_EXECUTE_AT_END(face_loop)
      {
       Domain *d;
       Thread *t;
       face_t f;
       int face_ID = 25;
       face = 0;


       d=Get_Domain(1);
       t=Lookup_Thread(d,face_ID);


       #if !RP_HOST
       begin_f_loop_int(f,t)
       {
        if(PRINCIPAL_FACE_P(f,t))
        face += 1;
       }
       end_f_loop_int(f,t)
       #endif


       #if RP_NODE
       face = PRF_GISUM1(face);
       #endif


       node_to_host_real_1(face);
      }



      DEFINE_ON_DEMAND(counting)
      {
       Message("Number of face %fn",  face);
      }


       


      The actual number of faces with face ID 25 is 2209.   But if I check with ON DEMAND, 'Number of faces is 1128.000000'.   I use it in parallel.   Face IDs 22, 23, and 24 have the same number of faces as face ID 25   ,but a value of 3572 or a strange value of 2256 is output.   I don't know what is wrong.

    • Kalyan Goparaju
      Ansys Employee

       


       


      Hellow


      The number of faces is always an integer value. Can you try re-initializing as "int face;"? More importantly, begin_f_loop_int is macro that needs to be avoided. Can you instead use begin_f_loop? 


      Thanks,


      Kalyan

    • mimimiming
      Subscriber

      Dear kgoparaj


      Thank you for your advice. But it does not work......;;


      In fact, the purpose of this UDF is to calculate the pressure drop of the porous media.


      I set the tube bundle of the huge furnace to porous media and use the equation 7.2-6 in the fluent user's guide 12.0.


      So I used the face loop because I need surface velocity and density values at the porous media inlet.


      So I have to calculate the value for every iteration.


      I would be grateful if you could tell me about other things than the face loop.


      Thanks.


       


      (p.s. I applied it to the interior face. I set the face to interior when modeling.)

    • Amine Ben Hadj Ali
      Ansys Employee

      All suggestions provided so far are correct. CAn you please debug your UDF by adding some messages. It is not very complicated thing.


      Domain, face_t and thread are not required on host but on node


      The number is integer and so you need to change the UDF and the node to host passing. The latter one you could at first ignore and just just Message0 in your at END macro to print the the number of counts. 


      To calculate the pressure drop, why are you using the UDF to count the faces? Anyway please refrain from using DEFINE_EXECUTE_AT_END. You will require DEFINE_PROFILE to prescribe the viscous and inertial coefficients as well as porosity.


       

    • mimimiming
      Subscriber

      Thank goodness. It has helped a lot.


      I'll ask you one last thing.


      I used a face loop to find the average value of the surface of the porous media inlet to obtain the inertial resistance of the porous media.


      For example, I need the average Z coordinate speed, so I wrote down the code below.


      (Initialization, declaration, etc. are omitted.)


       .


      .


      .


      t = Lookup_Thread(d,face_ID)


      begin_f_loop (f, t)
      {
      F_AREA (A, f, t);


      area = NV_MAG (A);
      total_area + = area;


      c0 = F_C (f, t);
      t0 = F_C0_THREAD (f, t);


      avg_z_vel + = area * fabs (C_W (c0, t0));
      }
      end_f_loop


      avg_z_vel / = total_area;


       


      Macros such as F_W (f, t) can not be used because the face to be calculated is an interior face, so I used C_W (c0, t0).

      In this way, calculate the porous media's inlet mean value (velocity, density) to calculate the porous media's inertial resistance.


      Is my idea correct?

    • Amine Ben Hadj Ali
      Ansys Employee

      Wrong; You need to build up an average of neighbouring cells.


      Just to remind you here: This is an open community and we from ANSYS we do not debug UDF'S. We just give a guideline.

Viewing 5 reply threads
  • The topic ‘fluent face loop’ is closed to new replies.