# average temperature of a face

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 6, 2018, 17:12 average temperature of a face #1 New Member   on Join Date: Nov 2018 Posts: 3 Rep Power: 7 Hello all, I am trying to find the average temperature of a face of a cube which is going to be used as inlet temperature to another domain. I am modelling a cube of stagnant water with inlet boundary condition at 323K. The output of my udf to calculate average temperature is coming zero! DEFINE_ADJUST(avg_temp,d) /*calc outlet temp average of water*/ { real tavg=0.0; face_t f; real A[ND_ND]; real area = 0.0; real area_tot = 0.0; Thread *t = Lookup_Thread(d,7); begin_f_loop(f,t) { F_AREA(A,f,t); area = NV_MAG(A); area_tot+=area; tavg+=F_T(f,t)*AREA; } end_f_loop(f,t) tavg/=area_tot; printf("avergae temperature of outlet of water is %f\n", tavg); printf("area total = %f\n", area_tot); } I am new to udf and would appreciate any help with this udf. Thank you!

 December 6, 2018, 19:21 #2 Senior Member   Join Date: Sep 2017 Posts: 246 Rep Power: 11 Hi Smukh, Assuming you've pasted your code accurately, the first error to look at is tavg+=F_T(f,t)*AREA; because "AREA" is not the same as "area". (C language is case-sensitive.) This should not get past a compiler without some warnings, or maybe errors. Please can you debug this and tell us what happens next? Does your code report a sensible value of area_tot? This UDF is suitable only for serial Fluent, of course. I would discourage use of "printf" in UDFs -- "Message" is safer. The difference is possibly small, but not necessarily. Good luck! Ed

 December 10, 2018, 15:57 #3 New Member   on Join Date: Nov 2018 Posts: 3 Rep Power: 7 Hi Ed, Thank you for your suggestions. I have successfully resolved it. It worked when I changed from DEFINE_ADJUST to DEFINE_EXCUTE_AT_END and AREA to area. I am not sure why I wasn't getting the value even after changing caps area, it was giving me no error while compiling. But as I did not need values for every iteration I was fine by replacing adjust by at end.

 Tags fluent - udf, fluent 18.0, temperature average value, udf code