
[Sponsors] 
April 15, 2012, 11:55 
Problem with DEFINE_UDS_FLUX

#1 
New Member
Ryan
Join Date: Mar 2012
Posts: 11
Rep Power: 5 
hi there,
I am learning to use DEFINE_UDS_FLUX macro, and I follow the UDF Manual example but somehow there's a problem : Here's my code: #include "udf.h" DEFINE_UDS_FLUX(ws_flux,f,t,i) { cell_t cO, c1=1; Thread *t0, *t1 = NULL; real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0; c0 = F_C0(f,t); t0 = F_C0_THREAD(f,t); F_AREA(A,f,t); if(BOUNDARY_FACE_THREAD_P(T)) { real dens; if(NNULP(THREAD_STORAGE(t,SV_DENSITY))) dens=F_R(f,t); else dens=C_R(c0,t0); NV_DS(psi_vec,=,F_U(f,t),F_V(f,t),F_W(f,t),*,dens) ; flux=NV_DOT(psi_vec,A); } else { c1=F_C1(f,t); t1=F_C_THREAD(f,t); NV_DS(psi_vec,=,C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),* ,C_R(c0,t0)); NV_DS(psi_vec,+=,C_U(c1,t1),C_V(c1,t1),C_W(c1,t1), *,C_R(c1,t1)); flux=NV_DOT(psi_vec,A)/2.0; } return flux; } And after I interpreting this macro, the command shows this error: Error: D:\ryan\source_code\ws_flux.c: line 11: THREAD_STORE: undeclared variable Can anybody help me? Any suggestion will be appreciated! best regard, Ryan Last edited by cfdmatteo; April 16, 2012 at 04:05. 

April 16, 2012, 03:41 

#2 
New Member
Andreas K
Join Date: Apr 2012
Location: Austria
Posts: 1
Rep Power: 0 
Hi Ryan,
I think you wrote a typo in line 11: t0 = F_C0_THEREAD(f,t); try t0 = F_C0_THREAD(f,t); instead good luck! 

April 16, 2012, 04:05 

#3  
New Member
Ryan
Join Date: Mar 2012
Posts: 11
Rep Power: 5 
Quote:
Thanks for your suggestion. : ) I'v fixed the code but still getting with the same problem. It seems the DEFINE_UDS_FLUX example of the Manual is of defect. Since I directly copy the code of example and somehow the same error comes up. 

April 16, 2012, 05:09 

#4  
New Member
Ryan
Join Date: Mar 2012
Posts: 11
Rep Power: 5 
Quote:
t0 = F_C0_THREAD(f,t) with t0 = THREAD_T0(t). But here comes other problems : for line 14 if(BOUNDARY_FACE_THREAD_P(T)) : Error: D:\ryan\source_code\ws_flux.c: line 14: parse error. and for line 20 dens = F_R(f,t); : Error: D:\ryan\source_code\ws_flux.c: line 20: dens: undeclared variable Any suggestion? Ryan 

April 22, 2012, 03:12 

#5  
Member
chenxizhong
Join Date: Feb 2012
Posts: 30
Rep Power: 5 
Hi, you have serval mistakes in your udf, here the correct one is following, any way do you used it in multiphase?
#include "udf.h" DEFINE_UDS_FLUX(ws_flux,f,t,i) { cell_t c0, c1=1; Thread *t0, *t1 = NULL; real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0; c0 = F_C0(f,t); t0 = F_C0_THREAD(f,t); F_AREA(A,f,t); if(BOUNDARY_FACE_THREAD_P(t)) { real dens; if(NNULLP(THREAD_STORAGE(t,SV_DENSITY))) dens=F_R(f,t); else dens=C_R(c0,t0); NV_DS(psi_vec,=,F_U(f,t),F_V(f,t),F_W(f,t),*,dens) ; flux=NV_DOT(psi_vec,A); } else { c1=F_C1(f,t); t1=F_C1_THREAD(f,t); NV_DS(psi_vec,=,C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),* ,C_R(c0,t0)); NV_DS(psi_vec,+=,C_U(c1,t1),C_V(c1,t1),C_W(c1,t1), *,C_R(c1,t1)); flux=NV_DOT(psi_vec,A)/2.0; } return flux; } Quote:


April 22, 2012, 05:24 

#6  
New Member
Ryan
Join Date: Mar 2012
Posts: 11
Rep Power: 5 
Quote:
Thanks a lot for your help. I am trying to calculate a multiphase problem. And as following your fixed code, it's still get some problem. Anyway, some say that might be a "interpreted or compiled" problem. Did you read this code by "interpreted" or by "compiled" in Fluent? I was interpreting it and always got errors as : Error: D:\ryan\paper comfirm\cfd_help_ws_flux.c: line 11: THREAD_STORE:undeclared variable 

April 22, 2012, 05:27 

#7  
Member
chenxizhong
Join Date: Feb 2012
Posts: 30
Rep Power: 5 
I use complie, there is no problem in my code
notice,the scalar transport in multiphase contain the volume fraction Quote:


April 22, 2012, 06:18 

#8 
New Member
Ryan
Join Date: Mar 2012
Posts: 11
Rep Power: 5 

April 22, 2012, 06:21 

#9 
Member
chenxizhong
Join Date: Feb 2012
Posts: 30
Rep Power: 5 

April 22, 2012, 06:37 

#10  
New Member
Ryan
Join Date: Mar 2012
Posts: 11
Rep Power: 5 
Quote:
I study on fuel cell calculating, and I use the PEMFC module of the Fluent but somehow the model is of defect. I think the multiphase model of this module is UFT model,but the flux term is neglected, so I try to fixed the problem by UDF. 

April 30, 2012, 02:27 
Udf help

#11 
Member
Join Date: Apr 2012
Location: Heidenheim
Posts: 51
Rep Power: 5 
Is there a predefined macro under which I can write a new model (combustion model). I dont plan to use any combustion model provided in FLUENT.
Please help. I want to link the advance combustion model to fluent. Under which DEFINE macro should I write my code??? Any help will be appreciate. 

July 29, 2014, 04:43 

#12  
New Member
Join Date: Jun 2014
Posts: 10
Rep Power: 3 
Quote:


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF compiling problem  Wouter  Fluent UDF and Scheme Programming  6  June 6, 2012 04:43 
Gambit  meshing over airfoil wrapping (?) problem  JFDC  FLUENT  1  July 11, 2011 05:59 
natural convection problem for a CHT problem  SeHee  CFX  2  June 10, 2007 06:29 
Adiabatic and Rotating wall (Convection problem)  ParodDav  CFX  5  April 29, 2007 19:13 
Is this problem well posed?  Thomas P. Abraham  Main CFD Forum  5  September 8, 1999 14:52 