CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF for imposing a BC (

mahesh July 14, 2003 01:14

UDF for imposing a BC
Hi All,

In a problem, I have to get average temperature from an outlet and impose it on another inlet. Following is a UDF, which is not complete, but, i think it is enough to explain my approach. I need your suggestions.

***************************************** # include "udf.h"

real temp=0.0;

DEFINE_ADJUST(get_temp,d) { Thread *t; face_t f;

d = Get_Domain(17); (17 is zone ID of the outlet) temp = F_T(f,t);(will this give me avg. temp at the outlet)

return temp; }

DEFINE_PROFILE(temp_profile,t,i) {

real x[ND_ND];

face_t f;

begin_c_loop(c,t) {


} **********************************

Andrew Garrard July 15, 2003 05:05

Re: UDF for imposing a BC
OK, I am not an expert on this, but I think you should consider the following points:

1) Your variables have to be continuous strings, e.g. realTemp or real_temp, but not real temp.

2) You are not actually doing anything with your DEFINE_ADJUST function. If you are defining the profile on the inlet you only need the DEFINE_PROFILE for the inlet.

3) When you use your Get_Domain macro I think you want the Lookup_Thread Macro instead.

4) You are making a face loop when you are not dealing with any faces, also the face loop is not doing anything.

Here is a suggested alternative:

DEFINE_PROFILE(temp_at_inlet, thread_inlet, i) { real temp; /* defining a variable */ Domain *domain = Get_Domain(domainID); /* where domainID is zone ID for domian */ fact_t f_inlet, f_outlet; /* defining faces at inlet and outlet */ Thread *thread_outlet = Lookup_Thread(domain, ThreadID) /* where thread ID is your ID for outlet face thread */

/* you will then want some sort of face loop macro for the averaging of the outlet temp e.g. */ begin_f_loop(f_outlet, thread_outlet) { } end_f_loop(f_outlet, thread_outlet)

and then another f_loop to implement the result into the inlet:

beging_f_loop(f_inlet, thread_outlet) { F_PROFILE(f_inlet, thread_outlet, i) = avg_temp; } end_f_loop(f_inlet, thread_outlet)

I just did this on the fly, but I think it is the right approch you should be using. Check the fluent manuals for the macros that I have used to make sure you use the correct arguments etc...

mahesh July 15, 2003 06:04

Re: UDF for imposing a BC
Hi Andrew,

Thanks a lot. I'll try it out.

Bye, Prasad

All times are GMT -4. The time now is 15:13.