Calculate inlet pressure in UDF

Tagged: ,

    • M F


      I would like to create a UDF that can measure the inlet pressure of my geometry (id = 6) and assign it to a variable (called p_a).

      I am struggling with the code since the pressure result does not seem to change with time, but it should since the inlet velocity is always varying. Here's what I have right now, and I would appreciate some input on what I may be doing wrong. Thank you in advance.

      real calculate_pa(Thread* tf)
          face_t f;
          real pa;
          real total_area;
          real total_pressure;
          real NV_VEC(va);

          Message(" START calculate_pa \n");
          total_area = 0.0;
          total_pressure = 0.0;

      #if !RP_HOST
          begin_f_loop(f, tf)
              if PRINCIPAL_FACE_P(f, tf)
                  F_AREA(va, f, tf);
                  total_area += NV_MAG(va);
                Message(" Loop: Total area [m^2] = %g \n", total_area);
                  total_pressure += F_P(f, tf) * NV_MAG(va);
                Message(" Loop: Total pressure [Pa m^2] = %g \n", total_pressure);
          }end_f_loop(f, tf);
        Message(" Total_area [m^2] = %g \n", total_area);
        Message(" Total_pressure [Pa m^2] = %g \n", total_pressure);
          pa = total_pressure / total_area;
          Message(" pa [Pa] = %g \n", pa);
          node_to_host_real_1(pa);    /*parallel*/
          return pa;
    • DrAmine
      Ansys Employee

      Why do you require within an UDF? What is the purpose of getting the inlet pressure in this way? 

      As an Ansys employee I do not debug code or write routines: but just compare the outcome to what you get through Surface integral.

      Also in the UDF always to do the reduction after finishing the Node calculations (you are missing that part)

      • M F

        Thank you very much for your reply. I need to use the inlet pressure to obtain the value of the outlet pressure. The UDF is meant to be used as a boundary condition in the outlet, and that's why I need to calculate the inlet pressure this way.

        I do not understand what reduction means, could you please explain or direct me to other material?

        • DrAmine
          Ansys Employee

          Look into the Customization manual and you will see functions starting with PRF_. You need to reduce the Sum of pressure and area before doing the ratio.

          Same can be achieved using Fluent Expressions wihtout writing a single UDF line. Have a look into the Fluent User's Guide and you will almost similar example like yours.

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