CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   DEFINE_ADJUST question (http://www.cfd-online.com/Forums/fluent-udf/77428-define_adjust-question.html)

ljp June 22, 2010 17:13

DEFINE_ADJUST question
 
Hi,

I need to define a variable using DEFINE_ADJUST macro, looping over all cells in all cell threads. Also I want to monitor another variable on a certain face, which requires to loop over the faces on only one face thread. I understand that if I only have the first part, then I only need to define one t and c, which will represent all cell threads. But since I also need to operate on a single face thread, can I just define two threads, one for the general thread and one for the specific face thread? Will that cause conflict during calculation?

I tried the following code, but I can't tell whether the result is right or not, since I'm not sure how to check the solutions, and the F_UDMI couldn't be displayed. Could anyone please tell me whether this is the correct way to do it? Thank you very much!

DEFINE_ADJUST(my_adjust, domain)
{
Thread *t;
cell_t c;

thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0) = C_T(c,t);
}end_c_loop(c,t)
}

Thread *tf = Lookup_Thread (domain, 3);
face_t f;
begin_f_loop(f, tf)
{
F_UDMI(f,tf,1) = Dm; //a constant
}
end_f_loop(f,tf)
}

thank you,
ljp

om1234 June 22, 2010 17:40

hi
u can use this one but as i know u need to change the number of udm memory in fluent.because as i know in each memory only one scaler value is stored.define>user define>memory
u can use both of them and it's not important to use single define_adjust,but u must write them in one udf like this:
no of memory=n_udm+1
#include "udf.h"
DEFINE_ADJUST(cells, domain)
{
Thread *t;
cell_t c;

thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
for(k=0;k<n_udm;k++)
C_UDMI(c,t,k) = C_T(c,t);
printf("vvvvvvvv:%f\n",C_UDMI(c,t,k));/*this is used to define values in graph window)
}
end_c_loop(c,t)
}

DEFINE_ADJUST(one face, domain)
{
face_t f;
int ID=3;
Thread *t = Lookup_Thread (domain, ID);

begin_f_loop(f, t)
{
F_UDMI(f,t,number of used memory in above udf) = Dm; //a constant
printf("name:%f\n",F_UDMI(f,t,number of used memory in above udf+1) );
}
end_f_loop(f,tf)
}

ljp June 23, 2010 09:51

Thank you so much for your reply, Omid. But I'm still not very clear. You used two DEFINE_ADJUST macro, but there's only one place to hook this udf, (or, only one adjust_udf can be hooked during the calculation), is that right? If I put these two parts of code into one adjust_udf, then will the two threads, t and tf, cause any conflict?

ljp


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