|
[Sponsors] |
January 23, 2015, 02:00 |
Hooking DEFINE_ON_DEMAND error??????????
|
#1 |
Member
Anh
Join Date: Sep 2014
Posts: 72
Rep Power: 12 |
Hi, I made UDF to calculate the local grid size for DES turbulence model in that delta=max(dx,dy,dz). Then compare the length scale of 2 equation model (Lt) and length of local grid delta. The results saved in C_UDMI=0 if (Lt>Cdes*delta) and C_UDMI=1 if (Lt<Cdes*delta) in order to plot the region where LES model is actived. But Fluent gave the error warning and could not do anything.
My code is described below (referent from one topic in forum) #include "udf.h" #include "math.h" DEFINE_ON_DEMAND(contour) { Domain *domain=Get_Domain(1); Thread *c_thread; cell_t c; Node *node; int n,i,j,counter=0; real delx1=0,dely1=0,delz1=0,dx,dy,dz,delta=0,lt,ldes,C des=0.65; real delx,dely,delz; real x[500],y[500],z[500]; thread_loop_c(c_thread,domain) /*loops over all cell threads in domain*/ { begin_c_loop(c,c_thread) /* loops over cells in a cell thread */ { c_node_loop(c,c_thread,n) /* loops over node in a cell thread */ { node=C_NODE(c,c_thread,n); NODE_MARK(node)=0; } c_node_loop(c,c_thread,n) /* loops over node in a cell thread */ { node=C_NODE(c,c_thread,n); x[counter]=NODE_X(node); y[counter]=NODE_Y(node); z[counter]=NODE_Z(node); counter=counter+1; if(NODE_MARK(node)==0) NODE_MARK(node)=1; } for (i=0; i<(counter-1); ++i) { for (j=i+1; j<counter; j++) { dx=fabs(x[i]-x[j]); dy=fabs(y[i]-y[j]); dz=fabs(z[i]-z[j]); delx=max(delx1,dx); dely=max(dely1,dy); delz=max(delz1,dz); delta=max(delx,dely); delta=max(delta,delz); } } lt=C_K(c,c_thread)/0.09/C_O(c,c_thread); ldes=Cdes*delta; if(lt>ldes) { C_UDMI(c,c_thread,1)=1; } if(lt<ldes) { C_UDMI(c,c_thread,1)=0; } } end_c_loop(c,c_thread) } } And the warning of Fluent is as in the picture below. Please give me the solution for this trouble!! Thank you very much. |
|
January 23, 2015, 03:59 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The problem is that you are using a serial code for parallel calculation. In parallel calculation, there is a host node, which does not do any calculation itself, but only distributes the data. (Simplified, but accurate enough for now.)
Your code is run on every node, so the host node is also asked to calculate the local grid, but it has no grid, so you get errors. At least that is what I think is going on. Two solution strategies: 1. Calculate (this part) in serial mode, with only one compute node. 2. Parallelize your serial UDF. See Fluent UDF manual, section 7.3, and 7.5.1. |
|
January 23, 2015, 10:58 |
|
#3 | |
Member
Anh
Join Date: Sep 2014
Posts: 72
Rep Power: 12 |
Quote:
You said the error because I run serial code in parallel calculation. But I also wrote UDF code for vaporation pressure which is very simple like this: #include "udf.h" #include "math.h" DEFINE_PROPERTY(vap_pre,c,t) { real pvar; real psat=2198; pvar=psat+0.5*0.39*C_R(c,t)*C_K(c,t); return pvar; } and doing with parallel calculation, but there are no error or warning from fluent. |
||
January 23, 2015, 11:04 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
And that is because in your "vap_pre" code, the parallel code and the serial code are the same.
If your code tries to look up something that has a position (like in your "contour" code, where you loop over all threads and nodes), serial code gives errors in parallel mode. If your code does not do that (like in your "vap_pre" code, where you define a property of a cell based on other properties of that cell), serial code and parallel code are the same. |
|
January 23, 2015, 11:16 |
|
#5 |
Member
Anh
Join Date: Sep 2014
Posts: 72
Rep Power: 12 |
Oh, I see, Thank you very much for your help
|
|
January 23, 2015, 11:49 |
|
#6 | |
Member
Anh
Join Date: Sep 2014
Posts: 72
Rep Power: 12 |
Quote:
Sorry, I have one more question. I read the parallel part in Fluent manual, and I include #if RP_HOST to my code, but the same warning and error still appare. When I use #if PARALLEL the code is ok and running in parallel calculation now. But it mean only serial process is calculted, isn's it? The code with #if RP_HOST #include "udf.h" #include "math.h" #include "sg_mem.h" DEFINE_PROPERTY(vap_Re3,c,t) { #if !RP_HOST real pvar; real psat=2198; pvar=psat+0.195*(C_RUV(c,t)+C_RVW(c,t)+C_RUW(c,t)) ; return pvar; #endif } and the similar one with #if !PARALLEL #include "udf.h" #include "math.h" #include "sg_mem.h" DEFINE_PROPERTY(vap_Re3,c,t) { #if !PARALLEL real pvar; real psat=2198; pvar=psat+0.195*(C_RUV(c,t)+C_RVW(c,t)+C_RUW(c,t)) ; return pvar; #endif } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problems with hooking UDF | whelk123 | Fluent UDF and Scheme Programming | 1 | August 30, 2010 08:39 |
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT | subhankar_bhandari | Fluent UDF and Scheme Programming | 0 | August 19, 2010 04:09 |
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT | subhankar_bhandari | FLUENT | 0 | August 19, 2010 04:01 |
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT | subhankar_bhandari | Main CFD Forum | 0 | August 19, 2010 04:01 |
10 reactions udf hooking | m&s | FLUENT | 0 | July 6, 2010 01:36 |