CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Adding a user-variable field in gas-solid flow case

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 5, 2012, 18:15
Default Adding a user-variable field in gas-solid flow case
  #1
New Member
 
Amir Hossein Ahmadi Motlagh
Join Date: Jan 2012
Posts: 5
Rep Power: 14
ahmadimo is on a distinguished road
I am a beginner in UDF programming and am simulating a 2D gas-solid fluidized bed and want to add an arbitrary user variable (just for test) which holds : rho_g*rho_s. I want to calculate this variable in every cell and show it in post-processing section to view contours. I also want to print it in console. In this way, I have used DEFINE_ON_DEMAND(on_demand_calc) function the following way:
Code:
/**********************************************************************
UDF to Print a new user variable Rho_g*Rho_s in a multiphase flow.
***********************************************************************/
#include "udf.h"

DEFINE_ON_DEMAND(on_demand_calc)
{
Thread *thread_g, *thread_s;
real rho_g, rho_s;
cell_t c;
Domain *g; 
Domain *mix_domain;
Domain *s;
g= Get_Domain(2);/* gas phase */
s= Get_Domain(3);/* solid phase*/
mix_domain = Get_Domain(1);

Thread *mix_thread = Lookup_Thread(mix_domain,1);

thread_g = THREAD_SUB_THREAD(mix_thread, 0);/* gas phase */
thread_s = THREAD_SUB_THREAD(mix_thread, 1);/* solid phase*/


/* Loop over all cells */
begin_c_loop(c,mix_thread)
{
rho_g = C_R(cell, thread_g);
rho_s = C_R(cell, thread_s);
printf("\n rho_g*rho_s= %g\n",rho_g*rho_s);
C_UDMI(c,mix_thread,0) = rho_g*rho_s;
}
end_c_loop(c,t)
}
I can not compile or interpret this UDF. Could anybody kindly check to see if I am going the right way and what is the problem with it?

errors when compiling:
Code:
..\..\src\rho_gs.c(18) : error C2275: 'Thread' : illegal use of this type as an expression
        c:\program files\ansys inc\v130\fluent\fluent13.0.0\src\mem.h(744) : see declaration of 'Thread'
..\..\src\rho_gs.c(18) : error C2065: 'mix_thread' : undeclared identifier
..\..\src\rho_gs.c(20) : error C2065: 'mix_thread' : undeclared identifier
..\..\src\rho_gs.c(20) : error C2223: left of '->sub_threads' must point to struct/union
..\..\src\rho_gs.c(21) : error C2065: 'mix_thread' : undeclared identifier
..\..\src\rho_gs.c(21) : error C2223: left of '->sub_threads' must point to struct/union
..\..\src\rho_gs.c(25) : error C2065: 'mix_thread' : undeclared identifier
..\..\src\rho_gs.c(25) : error C2223: left of '->nelements' must point to struct/union
..\..\src\rho_gs.c(27) : error C2065: 'cell' : undeclared identifier
..\..\src\rho_gs.c(28) : error C2065: 'cell' : undeclared identifier
..\..\src\rho_gs.c(30) : error C2065: 'mix_thread' : undeclared identifier
..\..\src\rho_gs.c(30) : error C2223: left of '->storage' must point to struct/union
errors when interpreting:
Code:
Error: C:\Users\ahmadimo\Desktop\FV\Ellis\rho_gs.c: line 18: parse error.
Error: C:\Users\ahmadimo\Desktop\FV\Ellis\rho_gs.c: line 20: mix_thread: undeclared variable
ahmadimo is offline   Reply With Quote

Old   January 5, 2012, 19:07
Default
  #2
Member
 
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 14
Sixkillers is on a distinguished road
You declared variable cell_t c, but in your code you are using variable called "cell" (in C_R method). So that is error reported by my compiler (GCC). In addition, variables s and g are not used (that is just two warnings).
Sixkillers is offline   Reply With Quote

Old   January 5, 2012, 19:13
Default
  #3
New Member
 
Amir Hossein Ahmadi Motlagh
Join Date: Jan 2012
Posts: 5
Rep Power: 14
ahmadimo is on a distinguished road
Quote:
You declared variable cell_t c, but in your code you are using variable called "cell" (in C_R method). So that is error reported by my compiler (GCC). In addition, variables s and g are not used (that is just two warnings).
Thanks for the reply. I corrected that , but the errors still remain. I think there might be a problem with this one:
Code:
Thread *mix_thread = Lookup_Thread(mix_domain,1);
but I am not sure what the problem is. Is the overall code doing the right thing? I would appreciate if someone could help me if I am going the right way or is it a better way of adding a new user-defined variable like the one I need (rho_g*rho_s).

Thanks
Amir
ahmadimo is offline   Reply With Quote

Old   June 1, 2013, 17:33
Default
  #4
Member
 
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 14
shashank312 is on a distinguished road
Amir, did you solve it eventually? If yes, then how? I would appreciate the help.
shashank312 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yplus [y+] value for gas solid two phase flow P.R.Naren Main CFD Forum 0 September 5, 2006 03:04
External flow field. Moon FLUENT 3 March 5, 2003 11:32
Gas pressure question Dan Moskal Main CFD Forum 0 October 24, 2002 23:02
Inviscid Drag at subsonic, subcritical Mach # Axel Rohde Main CFD Forum 1 November 19, 2001 13:19
fluid flow fundas ram Main CFD Forum 5 June 17, 2000 22:31


All times are GMT -4. The time now is 10:36.