how to parallel a udf?
i wrote a udf code in order to correct some field quantity during every time step by using EXECUTE_AT_END macro. when i want to run code in parallel it seems the code does not have access to domain. in other words computing core can not work together. here is the code :
#include "udf.h" DEFINE_EXECUTE_AT_END(Stabilazation) { Domain *d = Get_Domain(0); cell_t c; Thread *t; real x[ND_ND]; thread_loop_c(t, d) { C_CENTROID(x, c, t); Thread *t_water = THREAD_SUB_THREAD(t, 0); Thread *t_air = THREAD_SUB_THREAD(t, 1); begin_c_loop(c, t) { if (x[2] > 0.6) C_VOF(c, t_air) = 1.0; else C_VOF(c, t_air) = 0.0; } end_c_loop(c, t) } } any advice will be appreciated. |
i have encountered the similar problem, please try this modification:
#include "udf.h" DEFINE_EXECUTE_AT_END(Stabilazation) { #if !RP_HOST { Domain *d = Get_Domain(0); cell_t c; Thread *t; real x[ND_ND]; thread_loop_c(t, d) { C_CENTROID(x, c, t); Thread *t_water = THREAD_SUB_THREAD(t, 0); Thread *t_air = THREAD_SUB_THREAD(t, 1); begin_c_loop(c, t) { if (x[2] > 0.6) C_VOF(c, t_air) = 1.0; else C_VOF(c, t_air) = 0.0; } end_c_loop(c, t) } #endif } |
Hi Sepide, thanks for your reply,
i must have examined 1000 ways to fix it. the one you mentioned was tested and same problem exists. another problem arises because i tried to share threads! so the modification you suggested does not work :( i am working on it and any new suggestion will be appreciated. by the way i am a master student at khaje nasir university of technology. |
I'm in the same boat with trying to parallelize my code, but here's some things that I've found (which I haven't necessarily been able to implement successfully, segmentation faults everywhere) but might lead you in the right direction.
UDFs will be run on every single node, both compute and host nodes, so you'll have to state which nodes run which code by using compiler directives such as RP_NODE. 7.5.1 Compiler Directives 7.8 Parallel UDF Example Hope this helps. EDIT: Just noticed that ansys13 said the same thing I did. You might have to look into 7.5.9 Macros for Exchanging Data Between Compute Nodes to share the thread info. In my code, I'm trying to share the same data across nodes with use of reduction macros, but have been looking for better ways to do it. |
All times are GMT -4. The time now is 02:06. |