CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

How accessing derivatives in UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 13, 2003, 05:50
Default How accessing derivatives in UDF
  #1
Pietro Asinari
Guest
 
Posts: n/a
Hello everybody,

I'm writing a source terms by UDFs which need to access temperature derivatives C_T_G[i]. I have prevented the solver from freeing gradient data (solve/set/expert). In the code, I have inserted a control to verify the availability of gradient data:

if(!Data_Valid_P()) { source = 0; return source; }

The calculation works well and I save the results. When I try to load the DAT file, Fluent crashes for "Access Violation". It looks like "Data_Valid_P()" doesn't work.

What's the matter ?

Thank you in advance,

Pietro
  Reply With Quote

Old   October 13, 2003, 07:17
Default Re: How accessing derivatives in UDF
  #2
ap
Guest
 
Posts: n/a
You say the calculation works well, so Data_Valid_P() works, because it allows you to do the first iteration without errors when you try to access to gradients.

It's difficult to tell why this happens without looking to the code.

Do you use user defined memories or scalars?

Does the problems happens also when you load .cas and .dat files together?

Hi

ap
  Reply With Quote

Old   October 13, 2003, 08:30
Default Re: How accessing derivatives in UDF
  #3
Pietro Asinari
Guest
 
Posts: n/a
If I do some iterations without the source terms modelled by UDFs and then I turn on them, the calculation works well because temperature gradients have been correctly calculated. Saving the calculation, my UDFs are automatically linked to CASE file.

Restarting Fluent, the error occurs because temperature gradients are not stored into DATA file. The function "Data_Valid_P()" probably verifies the loading of DATA file but not what there is in. The starting check doesn't find temperature gradients into DATA file and crashes.

That's the code:

DEFINE_SOURCE(source_continuity, c, t, dS, eqn) {

/* ... code ... */

dT_dx_P = C_T_G(c,t)[0];

dT_dr_P = C_T_G(c,t)[1];

source=cost*sqrt(dT_dx_P*dT_dr_P);

return source; }

How can I add temperature gradients to DATA file ?

Thanks a lot,

Pietro

  Reply With Quote

Old   October 13, 2003, 09:13
Default Re: How accessing derivatives in UDF
  #4
Ale
Guest
 
Posts: n/a
Hi!

Try to add this control:

if (NULL != THREAD_STORAGE(t,SV_T_G))

{

....

} else

{

source=0.0;

}

I hope this helps. Regards,

Ale
  Reply With Quote

Old   October 13, 2003, 11:30
Default Re: How accessing derivatives in UDF
  #5
Pietro Asinari
Guest
 
Posts: n/a
Thank you very much, Ale !!

You have solved my troubles. The control you suggest works very well.

Regards,

Pietro
  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
Accessing profile data from a UDF ral007 Fluent UDF and Scheme Programming 0 March 22, 2011 11:29
UDF - Derivatives for User Defined Memory Variable Sandilya Garimella FLUENT 0 January 14, 2008 11:39
Accessing node values using a UDF Nico FLUENT 2 December 20, 2007 03:50
accessing solver data with UDF macros Dushan FLUENT 0 October 4, 2006 01:39
Accessing function definitions for UDF Karl FLUENT 2 February 14, 2002 09:29


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