Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Is there any specific procedure to implement Time-averaged UDF?

    • pmjsjs
      Subscriber

      I'm running a 2D-axisymmetric, density-based-solver, transient, parallel-UDF simulation. While using the macro, "p_mean=C_STORAGE_R(c,t,SV_P_MEAN)/delta_t", is there any specific procedure to implement it? For the time-averaged macro, I have even enabled 'Data sampling' under run calculation settings and have given a 'sample interval' of 10. And for obtaining the delta_t value, I used "delta_t=RP_Get_Real("delta-time-sampled)". In addition to this, I have also tried to run the simulation in serial mode. But, I get the following error;

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

      Node 0: Process 9808: Received signal SIGSEGV.

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

      The fl process could not be started.


      However, when I used the macro - C_STORAGE_R(c0,t0,SV_P), the UDF runs without any error. Can you suggest how to solve this error?

      Thanks in advance!

    • Karthik Remella
      Administrator
      Hello I don't think you need any special treatment on the Time-Sampled Data. Did you attempt to use message or fprintf statements in your UDF to see if your UDF is working correctly?
      Also, do check for any syntax-related issues in your UDF.
      Karthik
    • DrAmine
      Ansys Employee
      Are you enabling the data sampling?
    • pmjsjs
      Subscriber
      Thanks, Karthik and DrAmine for the response.
      So I have posted the UDF for your reference. The UDF works without any error until the final command, p_mean = C_STORAGE_R(c0,t0,SV_P_MEAN)/delta_t; is used. If this command is removed the entire code runs without any error. Even I have cross-checked if the code works by displaying the values in the console using the message command. Yes, it works.
      I tried both with and without the data sampling. Still, I have the same error "The fl process could not be started." when the final command (p_mean) is given. Can you suggest any better macros that can be employed here.
      Thanks in advance.

      #include "udf.h"
      real averagepr=0.0;
      DEFINE_EXECUTE_AT_END(average_pressure)
      Domain *d;
      real area[ND_ND];
      real pressure = 0.0;
      real f_area = 0.0;
      real total_area = 0.0;
      real pt = 0.0;
      real delta_t;
      real p_mean = 0.0;
      face_t f;
      cell_t c0;
      int ID = 23;
      Thread *thread, *t0;
      d = Get_Domain(1);
      thread = Lookup_Thread(d, ID);
      delta_t=RP_Get_Real("delta-time-sampled");
      begin_f_loop(f, thread)
      c0 = F_C0(f,thread);
      t0 = THREAD_T0(thread);
      F_AREA(area,f,thread);
      f_area = NV_MAG(area);
      total_area += NV_MAG(area);
      message("total area = %lf\n\n",total_area);
      pressure = C_STORAGE_R(c0,t0,SV_P);
      C_UDMI(c0,t0,0) = pressure;
      printf(" aspr %f \n\n", C_UDMI(c0,t0,0));
      pt += pressure*f_area;
      printf(" avg pr %f \n\n", pt);
      }
      end_f_loop(f,thread)
      averagepr = pt/total_area;
      printf(" the final avg pr = %f\n\n", averagepr);
      p_mean = C_STORAGE_R(c0,t0,SV_P_MEAN)/delta_t;
      printf(" the time avg pr = %f\n\n", p_mean);
      }

    • Rob
      Forum Moderator
      Set delta_t to a constant and see if that works.
    • pmjsjs
      Subscriber
      Hi Rob, thanks for the suggestion. I tried by setting delta_t to a constant, but unfortunately, it didn't work.
      I came across this link - http://www.cfd-online.com/Forums/blog_attachment.php?attachmentid=157&d=1375432014. In this link, they have mentioned a code for time-averaged values. I tried to run the same code, but it gives out the same error.
      I have cross-checked with the 2021 UDF manual, and have used only those time-averaged macro but doesn't seem working. Is there anything that is not in the manual that has to be added to it?
      I'm running this on ANSYS 2021 student version using in-built clang.
      Any leads would be a great help.

      Thanks in advance.
    • Rob
      Forum Moderator
      What happens if you run a few iterations with time averaging on and then turn on the UDF? Also see if it works with the Pressure Based Solver. Otherwise it' s not something I can answer.
Viewing 6 reply threads
  • The topic ‘Is there any specific procedure to implement Time-averaged UDF?’ is closed to new replies.