CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   return in udf (http://www.cfd-online.com/Forums/fluent/92643-return-udf.html)

wlt_1985 September 20, 2011 16:00

return in udf
 
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'?

Amir September 20, 2011 16:07

Quote:

Originally Posted by wlt_1985 (Post 324925)
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,

wlt_1985 September 21, 2011 02:26

Quote:

Originally Posted by Amir (Post 324927)
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.

KristianEtienne September 21, 2011 03:16

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!

Amir September 21, 2011 03:26

Quote:

Originally Posted by wlt_1985 (Post 324968)
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,

wlt_1985 September 21, 2011 05:35

Quote:

Originally Posted by Amir (Post 324977)
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. :)


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