I think, that you do not need UDF for this purpose. The "new" Fluent expression language should be entirely sufficient. You can formulate one or several expressions for evaluating the fluid temperature at desired locations or as a volume/surface integral (e.g. at the outlet cross section). Then you can formulate another expression for the heat source, which you make functionally dependent on the first (set of) expressions. if-then-else control structures are available as well in the expression language.