CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Problem in Parallel UDF (https://www.cfd-online.com/Forums/fluent/48502-problem-parallel-udf.html)

Giacomo de Renzi June 13, 2008 11:28

Problem in Parallel UDF
 
Hello, I've a problem using UDF with Parallel Computing: the main part of the UDF is a DEFINE EXECUTE AT END macro that calculates the average temperature on a face. In Serial Computing it works, but in Parallel Computing (and I need it!!!) it doesn't work fine because the macro is read by all partitions, while the face belongs to only one partition, how can I select the partition that is involved in the macro??

the UDF is attached below:

DEFINE_EXECUTE_AT_END(DEAE_T_rack_NO1_in) { real A_tot = 0.0; real ma_sum = 0.0; real T_sum = 0.0;

step = CURRENT_TIMESTEP; current_time = CURRENT_TIME; if (current_time > step) { Domain *d = Get_Domain(1);

real A[ND_ND]; Thread *t; face_t f; int id=62 ; /* ZONE ID RACK-NO1-IN */ t= Lookup_Thread(d,id);

begin_f_loop(f,t) { F_AREA(A,f,t); T_sum = T_sum + (F_T(f,t) * NV_MAG(A)); ma_sum = ma_sum + NV_MAG(A); } end_f_loop(f,t)

T_rack_NO1_in=T_sum/ma_sum; RP_Set_Real("controllo_no1",T_rack_NO1_in); } else {

T_rack_NO1_in = t_init; RP_Set_Real("controllo_no1",T_rack_NO1_in);

}

printf("T_rack_NO1_in: %g\n", T_rack_NO1_in); }

thank You, I hope someone could help me.. Giacomo de Renzi

lzw June 18, 2008 04:05

Re: Problem in Parallel UDF
 
As Fluent USER GUIDE says, in the parallel mode, the grids are divided to several partitions. In any partition, the faces are three types: interior face, boundary face, and the external face. Thus, it is different to loop the faces from the serial mode. In your loop, you should use the macro PRINCIPAL_FACE_P(f,t) to limit the faces.

Giacomo de Renzi June 18, 2008 05:17

Re: Problem in Parallel UDF
 
Thank you for answering me.. I tried using PRINCIPAL_FACE_P macro, but the UDF doesn't work, when I compile it the seguent messagge occurs (referred to the line where I used PRINCIPAL_FACE_P):"THREAD_STORE: undecleared variable"

It's very strange because the whole UDF which I wrote is the same of the example I found in UDF manual (9.6 Parallel UDF example); the only difference between mine and manual one is that my general macro is a DEFINE_EXECUTE_AT_END whereas in the manual there is a DEFINE_ADJUST, so I must add " Domain *d = Get_Domain(1); ", and I added it inside the first #if cicle...

could you tell me something to solve my problem?? thank you, Giacomo

lzw June 18, 2008 06:46

Re: Problem in Parallel UDF
 
I tested the example(9.6 Parallel UDF example), and I changed the DEFINE_ADJUST to the DEFINE_EXECUTE_AT_END. There is no compiling error. "Domain *d = Get_Domain(1);" should be placed in the #if !RP_HOST. Generally, the parallel UDF should work fine in the serial mode.

Giacomo de Renzi June 18, 2008 07:07

Re: Problem in Parallel UDF
 
Thank you for answering, I didn't try to compiling directly the udf of the manual but I tried to compile the mine, that's different in some parts, even if it's very similar.

I'm a newuser of fluent and I've not got much experience, my udf is the seguent, considering that certainly you have more experience than me, can you find what's wrong in it??

the error occurs in the line where there's "if (PRINCIPAL_FACE_P(f,t))",

thank you very much, I hope you could solve my problem (I'm going to degree on july, and this is the last obstacle I have to pass!!) Giacomo

DEFINE_EXECUTE_AT_END(DEAE_T_rack_NO1_in) { int id = 0; real ma_sum = 0.0; real T_sum = 0.0;

#if !RP_HOST Domain *d = Get_Domain(1); real A[ND_ND]; Thread* t; face_t f; #endif /* !RP_HOST */

#if !RP_NODE id=62 ; /* ZONE ID RACK-NO1-IN */ #endif /* !RP_NODE */

host_to_node_int_1(id);

#if !RP_HOST t= Lookup_Thread(d,id);

begin_f_loop(f,t) if (PRINCIPAL_FACE_P(f,t)) { F_AREA(A,f,t); T_sum += F_T(f,t) * NV_MAG(A); ma_sum += NV_MAG(A); } end_f_loop(f,t)

#if RP_NODE ma_sum = PRF_GRSUM1(ma_sum); T_sum = PRF_GRSUM1(T_sum); #endif /* RP_NODE */

#endif /* !RP_HOST */

node_to_host_real_2(ma_sum,T_sum);

#if !RP_NODE T_rack_NO1_in = T_sum/ma_sum; RP_Set_Real("controllo_no1",T_rack_NO1_in); printf("T_rack_NO1_in: %g\n", T_rack_NO1_in); #endif /* !RP_NODE */

}


lzw June 18, 2008 07:43

Re: Problem in Parallel UDF
 
Hello, I tested your udf in my fluent 6.2.16. There is no error except the variable "T_rack_NO1_in". Is is defined yourself?

Giacomo de Renzi June 18, 2008 07:55

Re: Problem in Parallel UDF
 
really??? then I really don't understand why it doesn't work in my fluent (6.3.26, but I don't think it's a problem about version used)

(the variable T_rack_NO1_in is defined before, that's not a problem for me)

did you use interpreted or compiled udf??

I've been always using 'interpreted', could be this the problem?

thank you very much!!!


lzw June 18, 2008 08:07

Re: Problem in Parallel UDF
 
Oh, I just use the compile mode, as I like this mode. And if your program is a little complicated, you should compile it. In my computer, I have installed the Visual Studio 2005. I started the fluent in the Visual Studio Command Window. Then load the source file and compile it directly. But I just had a problem too. I have four computers, each one has four CPU cores. I have just loaded the parallel UDF in one computer successfully(four cores). I failed to load the UDF if I used two computers to parallel(eight cores).

Giacomo de Renzi June 18, 2008 08:27

Re: Problem in Parallel UDF
 
I didn't understand well.. are you saying to me that my udf in your computer works in serial and not in parallel computing??

now I'm trying to use compiled way, could you tell me other possibility I could try??

thank you very much, Giacomo

lzw June 18, 2008 08:37

Re: Problem in Parallel UDF
 
No, I tested your udf in parallel way. You can try to compile it. This is a good way to debug your program. My OS is windows server 2003, and the compiler is the cl.exe of the Visual Studio 2005.

lzw June 18, 2008 08:39

Re: Problem in Parallel UDF
 
I mean I just could parallel the multi-CPUs in one computer, failed in two computers. Thus, present I just use four CPU cores to parallel in my calculation.

Giacomo de Renzi June 18, 2008 08:59

Re: Problem in Parallel UDF
 
thank you, I'm going to try in compiled way and I let you know.. thank you very much, Giacomo

Giacomo de Renzi June 18, 2008 12:19

Re: Problem in Parallel UDF
 
I've just solved my problem!!! the problem was really that I used interpret udf instead of compiled one!!

thank you very much, Giacomo


All times are GMT -4. The time now is 21:36.