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/)
-   -   Copying temperatures from one solid to another (https://www.cfd-online.com/Forums/fluent-udf/112649-copying-temperatures-one-solid-another.html)

Jeronimo97 February 1, 2013 18:10

Copying temperatures from one solid to another
 
Hi everyone. I'm here with some trouble trying to fix my UDF for a problem that it seemed to me that could be easy, but actually it revealed not to be.
I'm simulating a tempering furnace, and inside the furnace there are 6 solids that they jump from one position to another, in order to complete the process of tempering. I would like to simulate the change of position by simply changing the temperature of one solid to the solid of the next position, and set again to 293K (environment temperature) the temperature of the first solid in the line.
I have tried already lots of diferent things, but I was never able to see the UDF performing anything at all. I think that the main problem is that I need to be looping inside a thread and copy those values of temperature to another thread, and its not possible to have a loop over 2 threads at the same time. I have tried to copy all the cell values from the 6 threads to a matrice, and then impose the nem temperatures from there, but it didn't work. I always receive the message that ir performed the loop, but nothing happens.
Here is the last code that I tried, and the compiler had no problem running it.

#include "udf.h"
#define GALLOPING 20 /*proceeds the change of position at each 20s*/
int n = 1; /*counting of changes of position*/
int zone_id;
int zone_id1;

DEFINE_ADJUST(cell_temp,d)
{
real time = CURRENT_TIME;
cell_t c;
if(time == n * GALLOPING) /*time to update temperatures*/
for(zone_id = 7; zone_id > 1; zone_id--) /*loops from thread #7 till #2*/
{
Thread *t = Lookup_Thread(d,zone_id);
begin_c_loop_int(c,t)
{
C_UDMI(c,t,0) = C_T(c,t); /*saving the temperatures*/
}
end_c_loop_int(c,t)
} /*for*/
for(zone_id = 7; zone_id > 1; zone_id--)
{
zone_id1 = zone_id - 1;
if(zone_id > 2)
{
Thread *t = Lookup_Thread(d,zone_id);
Thread *t1 = Lookup_Thread(d,zone_id1);
begin_c_loop(c,t)
{
C_T(c,t) = C_UDMI(c,t1,0); /*imposing the new temperatures to the next position*/
}
end_c_loop(c,t)
}
else
{
Thread *t = Lookup_Thread(d,zone_id);
begin_c_loop(c,t)
{
C_T(c,t) = 293; /*putting a new solid in the furnace*/
}
end_c_loop(c,t)
}
} /*for*/
Message0("\Temperatures updated\n");
n += 1;
} /*if*/
} /*define_adjust*/


I would be very grateful if anyone could help me with this.
And then I would also need to parellize my function, but first things first.
Thanks in advance.
Jerónimo.

msaeedsadeghi February 3, 2013 04:26

I have done like these UDFs. You should first define "thread" of that solid, capture it's data, then use it in the new "thread".

Jeronimo97 February 3, 2013 15:39

Thanks for your reply, Saeed. Actually, I think I didn't understand your suggestion. Should I define just "Thread *t" outside the DEFINE_ADJUST function? I will always have to use the Lookup_Thread inside each for, since I only want to loop inside the solid threads.
How would you suggest to apply the temperatures to the next position? It seems to me that the C_UDMI doesn't allow what I want because I would need to loop over two threads at the same time. I have tried to copy the different cell and thread temperatures to a matrice, but it didn't work also.

msaeedsadeghi February 5, 2013 00:20

It works but need more cosideration. Try more :)

Jeronimo97 February 5, 2013 05:27

Needs more consideration on what? I was expecting a kind of more assertive answer. But it's OK.
You see, I've got this deadline to finish my thesis, and I'm only 10 weeks out from it. So, I haven't got that much time to waste on effortless tries. CFD is not my livelihood. I'm just a regular guy, trying to finish my degree in mechanical eng.. And that is why I came here, because there's nobody in my school that could help me on this.
Anyway, thank you Saeed for your suggestion.


All times are GMT -4. The time now is 19:27.