|
[Sponsors] |
January 17, 2016, 15:29 |
how to parallel a udf?
|
#1 |
Senior Member
B_Kia
Join Date: May 2014
Location: Ir
Posts: 123
Rep Power: 12 |
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. |
|
January 17, 2016, 16:06 |
|
#2 |
New Member
sepideh
Join Date: Mar 2014
Posts: 3
Rep Power: 12 |
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 } |
|
January 17, 2016, 17:43 |
|
#3 |
Senior Member
B_Kia
Join Date: May 2014
Location: Ir
Posts: 123
Rep Power: 12 |
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. |
|
January 19, 2016, 14:15 |
|
#4 |
New Member
Join Date: Sep 2013
Posts: 13
Rep Power: 13 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Define_Profile" UDF for parallel solver | Antoine | Fluent UDF and Scheme Programming | 9 | February 29, 2016 07:09 |
Problem in using UDF in parallel computing | Yogini | Fluent UDF and Scheme Programming | 0 | January 22, 2013 09:23 |
UDF Error with Parallel affter several step | trantoan2008 | Fluent UDF and Scheme Programming | 0 | January 7, 2013 08:33 |
Parallel UDF Error | Andrew | FLUENT | 2 | March 30, 2007 12:11 |
UDF in parallel version. | yobee | FLUENT | 0 | August 17, 2004 05:12 |