CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   average temperature of a face (https://www.cfd-online.com/Forums/fluent-udf/212703-average-temperature-face.html)

smukh December 6, 2018 17:12

average temperature of a face
 
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!:)

obscureed December 6, 2018 19:21

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

smukh December 10, 2018 15:57

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.


All times are GMT -4. The time now is 23:34.