|
[Sponsors] |
November 28, 2022, 10:59 |
parallel UDF issue in multiphase modeling
|
#1 |
New Member
Prasant
Join Date: Sep 2020
Location: India
Posts: 13
Rep Power: 6 |
Hi ...
I need to count the solid cells in the domain and assign the numbers to the solid cells. While running the UDF in series the solid cells are numbered consecutively. but while parallelising the udf to count the solid cells, the count always starts with zero for every comupter node. Due to this the solid cell count assignment stored in UDMI always begins with zero for every comupter node. I have attached the udf for reference and the udf results. I want to assign the max_count initial value for NODE-1= max_count final value in NODE-0. But in UDF results the max_count initialises always to zero for every NODE. Please suggest me how to assign the max_value before going through every NODE to non-zero value. |
|
November 28, 2022, 20:12 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
#include "udf.h" #include "mem.h" #include "prf.h" /// for global sum in parallel udf // #include "sg_mem.h" #include "sg_mphase.h" #include "para.h" DEFINE_ADJUST(solid_segregation,mix_domain) { int max_count,shift; #if !RP_HOST Domain *meltjet_domain; Thread *meltjet_thread; // meltjet thread pointer // cell_t cm; // melt jet cell identifier // meltjet_domain = Get_Domain(3); /* melt jet domain if multiphase */ thread_loop_c(meltjet_thread, meltjet_domain) //loops over all cell threads in domain// { begin_c_loop_int(cm, meltjet_thread) { shift+=1.0; } end_c_loop_int(cm, meltjet_thread) } thread_loop_c(meltjet_thread, meltjet_domain) //loops over all cell threads in domain// { Message("I am in the node process: %d\n", myid); Message("max_count at beginning of loop: %d\n", max_count); begin_c_loop_int(cm, meltjet_thread) { max_count+=1.0; if (C_VOF(cm,meltjet_thread) >= 0.5 && C_LIQF(cm, meltjet_thread) <= 0.90) { C_UDMI(cm, meltjet_thread,0)=1.0; // identify the solid cell: assign as 1 // C_UDMI(cm, meltjet_thread,2)= max_count+shift*myid; // numbering solid cells // } else { C_UDMI(cm, meltjet_thread,0)=0.0; // identify the liquid cell: assign as 0 // C_UDMI(cm, meltjet_thread,2)=0.0; // identify the liquid cell: assign as 0 // } } end_c_loop_int(cm, meltjet_thread) Message("max_count at end of loop: %d\n", max_count); } max_count = PRF_GISUM1(max_count); Message0("Real max_count at end: %d\n", max_count); #endif //* !RP_HOST */ }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 29, 2022, 03:14 |
|
#3 |
New Member
Prasant
Join Date: Sep 2020
Location: India
Posts: 13
Rep Power: 6 |
Hi.
Thanks for the response. I have modified the udf based on your suggestion to do numbering the solid cells in every computer NODE. The shift variable just multiplied to myid does not give the intended results as expected. I tried with the static variable option too, for the max_count variable. It still gives the zero value for the max_count for every computer NODE. How can I assign the max_count value of previous NODE to initialize the max_count during next NODE calculation instead of zero? |
|
November 29, 2022, 04:50 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try this
Code:
#include "udf.h" #include "mem.h" #include "prf.h" /// for global sum in parallel udf // #include "sg_mem.h" #include "sg_mphase.h" #include "para.h" DEFINE_ADJUST(solid_segregation,mix_domain) { int max_count,shift,i; int max_shift[compute_node_count]; #if !RP_HOST Domain *meltjet_domain; Thread *meltjet_thread; // meltjet thread pointer // cell_t cm; // melt jet cell identifier // meltjet_domain = Get_Domain(3); /* melt jet domain if multiphase */ thread_loop_c(meltjet_thread, meltjet_domain) //loops over all cell threads in domain// { begin_c_loop_int(cm, meltjet_thread) { if (C_VOF(cm,meltjet_thread) >= 0.5 && C_LIQF(cm, meltjet_thread) <= 0.90) { shift+=1.0; max_shift[myid] = shift; } } end_c_loop_int(cm, meltjet_thread) Message("shift index at NODE: %d\n", shift); } for(i=0; i<compute_node_count; i++) {if myid == i {shift += max_shift[myid]} } thread_loop_c(meltjet_thread, meltjet_domain) //loops over all cell threads in domain// { Message("I am in the node process: %d\n", myid); Message("max_count at beginning of loop: %d\n", max_count); Message("total sum count at beginning of loop: %d\n", (max_count+shift)); begin_c_loop_int(cm, meltjet_thread) { if (C_VOF(cm,meltjet_thread) >= 0.5 && C_LIQF(cm, meltjet_thread) <= 0.90) { max_count+=1.0; C_UDMI(cm, meltjet_thread,0)=1.0; // identify the solid cell: assign as 1 // C_UDMI(cm, meltjet_thread,2)= (max_count+shift)); // numbering solid cells // } else { C_UDMI(cm, meltjet_thread,0)=0.0; // identify the liquid cell: assign as 0 // C_UDMI(cm, meltjet_thread,2)=0.0; // identify the liquid cell: assign as 0 // } } end_c_loop_int(cm, meltjet_thread) Message("total sum count at end of loop: %d\n", (max_count+shift)); } max_count = PRF_GISUM1(max_count); Message0("Real max_count at end: %d\n", max_count); #endif //* !RP_HOST */ }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issue with UDF in parallel processing | MC1 | FLUENT | 5 | August 29, 2017 04:17 |
Viscous dissipation UDF for multiphase DDPM (Divergence problem) | bhargavbharathan | FLUENT | 0 | November 30, 2016 13:23 |
Viscous dissipation UDF for multiphase DDPM | bhargavbharathan | Fluent Multiphase | 0 | November 30, 2016 13:17 |
Identifying cell in parallel UDF | upeksa | Fluent UDF and Scheme Programming | 0 | July 24, 2013 12:27 |
Help: how to realize UDF on parallel cluster? | Haoyin | FLUENT | 1 | August 6, 2007 14:53 |