CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF: Repatching part temperature (https://www.cfd-online.com/Forums/fluent/31564-udf-repatching-part-temperature.html)

Mcgregor May 29, 2003 09:09

UDF: Repatching part temperature
 
Hi all,

I have written the following program that should repatch the temperature of a part, when the average temperature of another part reaches a given value.

On the first iteration of every timestep, the average temperature of thread 2 is calculated using the first part of the program and it also prints this value.

The second half of the program should reassign the cell temperature values for all of the cells in thread 4 once the average temp = 350K.

At the moment this is not happening, but i know that the final loop is being entered at the correct time because the ave temp value is printed a second time in the console window. Please help!!!!

Why does my program not reassign temperature values to the cells in thread 2?

Andy

#include "udf.h"

int last_ts = -1; /* Global variable. Time step is never <0 */

DEFINE_ADJUST(repatch_saveb,d)

{ int curr_ts; curr_ts = RP_Get_Integer("time-step");

if (last_ts != curr_ts)

{ last_ts = curr_ts; {

real Ttot; real Tave;

Thread *t; cell_t c;

int ID =2; int ID2 = 4;

t = Lookup_Thread(d,ID);

begin_c_loop(c,t)

Ttot +=C_T(c,t);

end_c_loop(c,t);

Tave = (Ttot/168.0);

printf("\n Ttot= %g Tave= %g",Ttot,Tave);

if (Tave<350.0)

{ printf("\n Ttot= %g Tave= %g",Ttot,Tave);

t = Lookup_Thread(d,ID2);

begin_c_loop(c,t)

C_T(c,t) = 493.0;

end_c_loop(c,t);

}

}

} }


Markus June 2, 2003 08:51

Re: UDF: Repatching part temperature
 
Hi Andy,

For transient problems the temperature value of the previous time step acts like a source term for the energy equation of a given cell. I suggest you should consider to adjust C_T_M1(c,t), too.

br Markus


All times are GMT -4. The time now is 00:48.