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

something wrong when compiling udf, however the code is correct when interpreting

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 30, 2013, 11:59
Default something wrong when compiling udf, however the code is correct when interpreting
  #1
Member
 
ben
Join Date: Apr 2013
Posts: 36
Rep Power: 13
richard ben is on a distinguished road
Hey, everyone,

I began to change my udf from interpet to compile, however meet some problem and have no idea how to do.

1. The diffusivity

the code:

DEFINE_DIFFUSIVITY(uds_diffusivity_2,c,t,i)
{
return s_lamda*(1.0-POR)/3.0;
}
when I load this code, the uds goes to divergence. However, when I change "s_lamda*(1.0-POR)/3.0" into a constant, it works fine. In fact, s_lamda*(1.0-POR)/3.0 is a constant in my code since I defined "s_lamda" and "POR" in the begining of the code. This is weird

2. The source term

the code:
DEFINE_SOURCE(fluid_source_1,c,t,dS,eqn)
{
real Re, P, alamda_f, h,source_f;
alamda_f=C_K_L(c,t);
Re=C_U(c,t)/POR*ds*C_R(c,t)/C_MU_L(c,t);
P=-8.278*pow(POR,0.38)+57.384*pow(POR,1.38)-106.63*pow(POR,2.38)+95.756*pow(POR,3.38)-37.24*pow(POR,4.38);
h=2.096*pow(POR,0.38)*alamda_f*pow(Re,0.438)*P/(ds*ds);
source_f=h*(C_UDSI(c,t,0)-C_T(c,t));
dS[eqn]=-h;
return source_f;
}

I can load this source without any problem when interpreting, however in compiling it doesn't work at all. And the error is:
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: #f

I have no idea what's wrong with my code or is there any difference between compile and interpret?

I will appreciate a lot for your help.
richard ben is offline   Reply With Quote

Old   April 30, 2013, 12:14
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
You could use "THREAD_STORAGE" as the keyword to search in the fluent udf manual. You have tried to access the pointers before the spaces they associated to are allocated.
blackmask is offline   Reply With Quote

Old   April 30, 2013, 22:31
Default
  #3
Member
 
ben
Join Date: Apr 2013
Posts: 36
Rep Power: 13
richard ben is on a distinguished road
Thank you very much for your reply. I didn't get you. I can load this source term in interpreted UDFs. And when I load it in compiled UDFs, I have two UDSs. And I can display C_UDSI(c,t,0) but just cannot load this source term.
richard ben is offline   Reply With Quote

Old   April 30, 2013, 23:13
Default
  #4
Member
 
ben
Join Date: Apr 2013
Posts: 36
Rep Power: 13
richard ben is on a distinguished road
hey blackmask,

I know the reason but still have no idea how to solve it.
the problem locates in this code : alamda_f=C_K_L(c,t)
when I change C_K_L(c,t) into a constant, it works fine.
So the problem is I can't cite using C_K_L(c,t) ? Why?
Do you have any ideas? Or this is the problem you mentioned.
Access it without allocated?
richard ben is offline   Reply With Quote

Old   April 30, 2013, 23:40
Default
  #5
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Give it a try.

Quote:
Originally Posted by richard ben View Post
2. The source term

the code:
DEFINE_SOURCE(fluid_source_1,c,t,dS,eqn)
{
real Re, P, alamda_f, h,source_f;

if (!Data_Valid_P())
return;


alamda_f=C_K_L(c,t);
Re=C_U(c,t)/POR*ds*C_R(c,t)/C_MU_L(c,t);
P=-8.278*pow(POR,0.38)+57.384*pow(POR,1.38)-106.63*pow(POR,2.38)+95.756*pow(POR,3.38)-37.24*pow(POR,4.38);
h=2.096*pow(POR,0.38)*alamda_f*pow(Re,0.438)*P/(ds*ds);
source_f=h*(C_UDSI(c,t,0)-C_T(c,t));
dS[eqn]=-h;
return source_f;
}


blackmask is offline   Reply With Quote

Old   May 1, 2013, 05:27
Default
  #6
Member
 
ben
Join Date: Apr 2013
Posts: 36
Rep Power: 13
richard ben is on a distinguished road
hey blackmask,

thank you for your suggestion. it didn't work. however i solved this problem by setting the thermal conductivity into a picewise-polynomial function related to the temperature. if the thermal conductivity is set to be a constant then it didn't work and the same error. i don't know why but it is solved.

however i met another problem. do you know what is the meaning of this code?
Thread *t0=thread-t0;
when i compiled the udfs the warnings are:
'initializing' : 'struct thread_struct *' differs in levels of indirection from 'int '
local variable 't0' used without having been initialized

although i can ignore these two wranings, when i load this udf containing this code
it doesn't work. so i check the code one by one, and found that this code might be the problem.
but have no idea how to intialize 't0'

do you have any ideas? i will appreciat a lot for your help.
richard ben is offline   Reply With Quote

Old   May 1, 2013, 07:02
Default
  #7
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Could it be thread_t0? This line can only be understood in context.
blackmask is offline   Reply With Quote

Old   May 11, 2013, 08:36
Default
  #8
Member
 
ben
Join Date: Apr 2013
Posts: 36
Rep Power: 13
richard ben is on a distinguished road
thank you for your help and sorry for the delayed reply.
This code is copied in the UDF manual Charpter 8.2.5.2.
I assumed it was wrong and thought it should be Thread *t0=thread
Is it ok?
richard ben is offline   Reply With Quote

Reply


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
please help me to correct my code Ardalan Main CFD Forum 1 June 2, 2010 19:32
UDF compiling problem in Flient 6.3 jeevan kumar FLUENT 2 February 25, 2009 01:43
What's wrong with my UDF? It worked in the past. CF FLUENT 3 September 26, 2007 21:09
compiling a UDF co2 FLUENT 2 January 5, 2004 20:34
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 16:56


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