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

Problem in UDF compilation

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

Like Tree1Likes
  • 1 Post By Galileo

Reply
 
LinkBack Thread Tools Display Modes
Old   May 31, 2012, 13:24
Default Problem in UDF compilation
  #1
New Member
 
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 4
iitgbim is on a distinguished road
here is part of udf, where I am getting error (not defined variable)

# include "udf.h"
# define C 0.3
# define diam2 2.e-4
# define Cmu 0.09

DEFINE_EXCHANGE_PROPERTY(modified_drag,cell,mix_th read,s_col,f_col)

{
Thread*thread_l;
Thread*thread_g;

real slip_x;
real slip_y;
real slip_z;
real slip;
real k_l;
real d_l;
real mu_t_l;
real mu_l;
real rho_l;
real rho_g;
real reyp;
real cd;

/* liquid phase-primary*/

thread_l=THREAD_SUB_THREAD(mix_thread,s_col);

/* gas phase-secondary*/

thread_g=THREAD_SUB_THREAD(mix_thread,f_col);

/* slip velocity*/

slip_x=C_U(cell,thread_l)-C_U(cell,thread_g);
slip_y=C_V(cell,thread_l)-C_U(cell,thread_g);
slip_z=C_W(cell,thread_l)-C_W(cell,thread_g);

/*Parameters*/

rho_g = C_R(cell, thread_g);
rho_l = C_R(cell, thread_l);
mu_l = C_MU_L(cell, thread_l);

/*turbulent kinetic energy and dissipation rate for liquid*/

k_l=C_K_L(cell,thread_l);
d_l=C_D_L(cell,thread_l);

It says C_D_L is not defined
iitgbim is offline   Reply With Quote

Old   May 31, 2012, 14:45
Default
  #2
Member
 
Fer Villa
Join Date: Apr 2012
Posts: 35
Rep Power: 4
fevi84 is on a distinguished road
In Fluent,

the turbulent kinetic energy is:C_K(c,t)

the turbulent kinetic energy dissipation rate is: C_D(c,t)

C_K_L(c,t) is laminar thermal conductivity

C_D_L(c,t) I don't know. you are sure that variable macro there
fevi84 is offline   Reply With Quote

Old   June 1, 2012, 00:34
Default
  #3
New Member
 
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 4
iitgbim is on a distinguished road
I have intended to model a new drag law for two-phase flow (gas -liquid).

Here L denotes the liquid phase. Here is the full UDF. Please go through and suggest me why it is saying d_l=C_D_L(cell,thread_l); C_D_L is undeclared variable.
Attached Files
File Type: c udf1.c (1.5 KB, 34 views)
iitgbim is offline   Reply With Quote

Old   June 1, 2012, 09:59
Default
  #4
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 6
Galileo is on a distinguished road
Quote:
Originally Posted by iitgbim View Post
I have intended to model a new drag law for two-phase flow (gas -liquid).

Here L denotes the liquid phase. Here is the full UDF. Please go through and suggest me why it is saying d_l=C_D_L(cell,thread_l); C_D_L is undeclared variable.
Hi,

You are modelling a two phase flow. Fluent does not know if one phase is liquid or not, it only knows it as "one phase" and the "other phase". You are the one referring to one of the phases as liquid. Fluent knows the cell content with the thread.

Therefore, appending _L to the variable does not mean the variable will refer to the liquid phase. You should call the correct thread.
If you could have written it as C_D_S to mean solid and C_D_V to mean vapour and your code will not run (or run correctly). If you add _G to mean Gas you will be wrong because most of the _G in the variables refer to gradient.

To answer your question, I will suggest you do the following.
(1) Turn on the correct Turbulence model (k-eps) I guess.
(2) Change your code lines to:
/*turbulent kinetic energy and dissipation rate for liquid*/
k_l=C_K(cell,thread_l);
d_l=C_D(cell,thread_l);



You have to be sure these refer to the correct threads respectively:
/* liquid phase-primary*/
thread_l=THREAD_SUB_THREAD(mix_thread,s_col);
/* gas phase-secondary*/
thread_g=THREAD_SUB_THREAD(mix_thread,f_col);


If your code works please reply in this thread it may help someone else.
DungPham likes this.
Galileo is offline   Reply With Quote

Old   June 1, 2012, 10:23
Default
  #5
New Member
 
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 4
iitgbim is on a distinguished road
Thanks

It is working.
iitgbim is offline   Reply With Quote

Old   June 1, 2012, 10:52
Default
  #6
New Member
 
Tamphasana
Join Date: Jun 2012
Posts: 9
Rep Power: 4
thiyam is on a distinguished road
thanks for you reply Galileo, the same udf code has successfully interpreted but the problem is while doing iteration it shows error like
FLUENT received fatal signal (ACCESS_VIOLATION)

This problem has solved now but again after exactly 11th iteration error shows as

Error: divergence detected in AMG solver:k
Error Object)

I need your help

Last edited by thiyam; June 1, 2012 at 11:34.
thiyam is offline   Reply With Quote

Old   June 1, 2012, 11:18
Default
  #7
New Member
 
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 4
iitgbim is on a distinguished road
The udf is working fine but when i go for iteration, it shows error like Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: ()


Please suggest me
iitgbim is offline   Reply With Quote

Old   June 4, 2012, 01:30
Default
  #8
New Member
 
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 4
iitgbim is on a distinguished road
While compiling I am getting Warning C4700: Local variable mu_l used without having been initialized.

I am also getting no changes in gas phase wile iterating. Please suggests me.
iitgbim is offline   Reply With Quote

Old   June 5, 2012, 01:44
Default
  #9
New Member
 
Join Date: Aug 2009
Posts: 6
Rep Power: 6
amindavari is on a distinguished road
could anyone help me: i provided an udf that set a profile on the boundary, at first i couldnt even interprete this udf, however by adding two lines in code i finally could interprete it. now i encounter a new problem, when i start iterating, an error entitled "Floating point error: invalid number" appears. what should i do?
thank you in advance


#include "udf.h"
DEFINE_PROFILE(heatflux, thread, position){
#if !RP_HOST
real y[ND_ND]; /* this will hold the position vector */
real z;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
z = y[2];
F_PROFILE(f, thread, position) = 283889.07*cos((4.0*atan(1.0)/0.815)*(z+0.01005));
}
end_f_loop(f, thread)
#endif
}
amindavari is offline   Reply With Quote

Old   June 7, 2012, 09:56
Default
  #10
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 6
Galileo is on a distinguished road
Quote:
Originally Posted by iitgbim View Post
While compiling I am getting Warning C4700: Local variable mu_l used without having been initialized.

I am also getting no changes in gas phase wile iterating. Please suggests me.

Hi,

Sorry for the late response.
1.)
That warning is telling you that you have declared a variable but you did not initialise it before using it.

That can be ignored or you put an initial value like in this example:

real mu_l=0.;
or
/* DECLARATIONS of variables */

real a;
real b;
real mu_l;
/* Initialising varibles */

a=b=mu_l=0.;




2.)
I don't really know what you are trying to achieve, but generally when you write a code like that, you need to HOOK the UDF to the interface. So please check UDF manual for how to hook your particular UDF to FLUENT. You may want to check this: FLUENT MANUAL
Galileo is offline   Reply With Quote

Old   June 7, 2012, 10:11
Default
  #11
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 6
Galileo is on a distinguished road
Quote:
Originally Posted by amindavari View Post
could anyone help me: i provided an udf that set a profile on the boundary, at first i couldnt even interprete this udf, however by adding two lines in code i finally could interprete it. now i encounter a new problem, when i start iterating, an error entitled "Floating point error: invalid number" appears. what should i do?
thank you in advance


#include "udf.h"
DEFINE_PROFILE(heatflux, thread, position){
#if !RP_HOST
real y[ND_ND]; /* this will hold the position vector */
real z;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
z = y[2];
F_PROFILE(f, thread, position) = 283889.07*cos((4.0*atan(1.0)/0.815)*(z+0.01005));
}
end_f_loop(f, thread)
#endif
}

Hi,
You need to check if it is a machine issue (eg are you using double or single precision solver?). Try and change the solver.

You can also check through to understand what is going on at the stage of iteration and debug, just like you will debug any "normal" code.


int Stopper;
Stopper=0;
#if !RP_HOST
real y[ND_ND]; /* this will hold the position vector */
real z;
real ATAN,COS,Profile;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
z = y[2];

ATAN=atan(1.0);
COS= cos((4.0*ATAN/0.815);
Profile=283889.07*COS*(z+0.01005));
if (Stopper<20)
{Stopper++; /*Print only twenty times DONT HANG MY COMPUTER INSIDE A LOOP */
CX_Message(" Z= %g Atan=%g Cos=%g Profile Val=%g",z,ATAN,COS,Profile);

}
F_PROFILE(f, thread, position) =Profile;
}
end_f_loop(f, thread)
#endif


Hope it works/helps?

Last edited by Galileo; June 7, 2012 at 10:33.
Galileo is offline   Reply With Quote

Old   June 7, 2012, 10:22
Default
  #12
Member
 
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 6
Galileo is on a distinguished road
Quote:
Originally Posted by thiyam View Post
thanks for you reply Galileo, the same udf code has successfully interpreted but the problem is while doing iteration it shows error like
FLUENT received fatal signal (ACCESS_VIOLATION)

This problem has solved now but again after exactly 11th iteration error shows as

Error: divergence detected in AMG solver:k
Error Object)

I need your help

Hi,
That error might be that you are attempting to access a variable from a model you are not using. Eg If you are accessing turbulence variables from UDF while your model setup is laminar, you will face such issue. If also, you are solving a model with k-epsilon and you are trying to access FLUENT data from k-omega, you will also face such.

Try and look through the variables and be sure you have switched on the correct variable.

If you face divergence problem, it is possible you have the wrong discritisation scheme and your solution is not converging. It is also possible you are getting a division by zero or too big number. So debug your code by printing the values you are changing. You can print using: (Formatting using C-formating). But becareful when printing inside a big loop. You can use a stopping criteria to stop print, eg using a counter variable.

CX_Message("*****VARIABLES C_Mu =%E, C_K=%E", c_mu,c_k);
Galileo is offline   Reply With Quote

Old   June 9, 2012, 03:21
Default
  #13
New Member
 
Join Date: Aug 2009
Posts: 6
Rep Power: 6
amindavari is on a distinguished road
Quote:
Originally Posted by Galileo View Post
Hi,
You need to check if it is a machine issue (eg are you using double or single precision solver?). Try and change the solver.

You can also check through to understand what is going on at the stage of iteration and debug, just like you will debug any "normal" code.


int Stopper;
Stopper=0;
#if !RP_HOST
real y[ND_ND]; /* this will hold the position vector */
real z;
real ATAN,COS,Profile;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
z = y[2];

ATAN=atan(1.0);
COS= cos((4.0*ATAN/0.815);
Profile=283889.07*COS*(z+0.01005));
if (Stopper<20)
{Stopper++; /*Print only twenty times DONT HANG MY COMPUTER INSIDE A LOOP */
CX_Message(" Z= %g Atan=%g Cos=%g Profile Val=%g",z,ATAN,COS,Profile);

}
F_PROFILE(f, thread, position) =Profile;
}
end_f_loop(f, thread)
#endif


Hope it works/helps?
Thank you for the response.

it should be mentioned that this code works properly by one processor. however, when i use parallel mode in fluent, i encounter this error after iteration. can i interprete udf in parallel mode or should compile?
amindavari is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 30 March 21, 2014 06:34
UDF problem mansha goraya FLUENT 0 October 29, 2007 01:31
udf compiling problem akr FLUENT 3 August 22, 2007 07:14
UDF PROBLEM anant FLUENT 2 January 17, 2007 00:15
parallel UDF problem kerem FLUENT 2 June 20, 2006 06:56


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