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

return in udf

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2011, 16:00
Default return in udf
  #1
Senior Member
 
raymond
Join Date: Nov 2009
Posts: 149
Rep Power: 17
wlt_1985 is on a distinguished road
What is the main function of 'return' in udf? Since I had gone through the guide and I found that certain udf with 'return' while some did not. What the different of udf with 'return' and udf with no 'return'?
wlt_1985 is offline   Reply With Quote

Old   September 20, 2011, 16:07
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by wlt_1985 View Post
What is the main function of 'return' in udf? Since I had gone through the guide and I found that certain udf with 'return' while some did not. What the different of udf with 'return' and udf with no 'return'?
Dear Raymond,
if your macro is void-type, it wouldn't return any value and it just does some settings, but if it isn't void-type, it return a value and needs return command.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   September 21, 2011, 02:26
Default
  #3
Senior Member
 
raymond
Join Date: Nov 2009
Posts: 149
Rep Power: 17
wlt_1985 is on a distinguished road
Quote:
Originally Posted by Amir View Post
Dear Raymond,
if your macro is void-type, it wouldn't return any value and it just does some settings, but if it isn't void-type, it return a value and needs return command.

Bests,
Thanks Amir. For example, I am having changes in species during the modelling, then I am either using macro DEFINE_SOURCE or DEFINE_VR_RATE. DEFINE_SOURCE does have 'return' while DEFINE_VR_RATE does not have. Does it mean that DEFINE_VR_RATE just doing some setting which has been pre-defined in Fluent while DEFINE_SOURCE calling for calculation and return the value to the model? Please help.
wlt_1985 is offline   Reply With Quote

Old   September 21, 2011, 03:16
Default
  #4
New Member
 
Kristian Etienne Einarsrud
Join Date: Oct 2010
Location: Trondheim
Posts: 29
Rep Power: 16
KristianEtienne is on a distinguished road
Hi,

Your reasoning is correct; In DEFINE_SOURCE, you return the value of the source directly (through the "return" command), while in DEFINE_VR_RATE you update the specific reaction rate pointer (*rr_t) which is predefined by FLUENT.

Cheers!
KristianEtienne is offline   Reply With Quote

Old   September 21, 2011, 03:26
Default
  #5
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by wlt_1985 View Post
Thanks Amir. For example, I am having changes in species during the modelling, then I am either using macro DEFINE_SOURCE or DEFINE_VR_RATE. DEFINE_SOURCE does have 'return' while DEFINE_VR_RATE does not have. Does it mean that DEFINE_VR_RATE just doing some setting which has been pre-defined in Fluent while DEFINE_SOURCE calling for calculation and return the value to the model? Please help.
Exactly; in DEFINE_SOURCE, there isn't any argument which refers to source value, so we define a real variable, e.g. source, and use return function at the end;
Code:
return source
But in DEFINE_VR_RATE, there are two argument which are pre-defined for FLUENT and you can store desired data in them. It's defined for this macro which variable should be returned, so you wouldn't need return command.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   September 21, 2011, 05:35
Default
  #6
Senior Member
 
raymond
Join Date: Nov 2009
Posts: 149
Rep Power: 17
wlt_1985 is on a distinguished road
Quote:
Originally Posted by Amir View Post
Exactly; in DEFINE_SOURCE, there isn't any argument which refers to source value, so we define a real variable, e.g. source, and use return function at the end;
Code:
return source
But in DEFINE_VR_RATE, there are two argument which are pre-defined for FLUENT and you can store desired data in them. It's defined for this macro which variable should be returned, so you wouldn't need return command.

Bests,
Thanks Amir.
wlt_1985 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
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
Parallelizing a UDF tstorm Fluent UDF and Scheme Programming 3 August 20, 2009 13:31
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
I need UDF help. S.Whitney FLUENT 0 October 15, 2007 12:29
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


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