CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Looping inside a UDF (https://www.cfd-online.com/Forums/fluent-udf/121908-looping-inside-udf.html)

sayan_bose August 7, 2013 14:29

Looping inside a UDF
 
I want to calculate the sum of N no.of terms inside my udf and these terms are not associated with any cell of face variables, so cell loop and thread loop are of no use. I want some sort of "for loop" type device which I can use in a UDF to do this summation.
Thanks in advance.

macfly August 7, 2013 15:02

Hi,

Have you read the UDF manual? Here's what I found in 5 minutes, for example execute some loop at the end of each timestep:

Code:

DEFINE_EXECUTE_AT_END(execute_at_end)
{
/* Print integers 1-10 and their squares */
 int i, j;
 for (i = 1 ; i <= 10 ; i++)
  {
    j = i*i;
    printf("%d %d\n",i,j);
  }
}


sayan_bose August 8, 2013 16:21

Thanks for your suggestion, but I need to run the "for" loop inside a DEFINE_DPM_BOFY_FORCE udf, at that to during every iteration not after the iterations. So do you have any solution for that.
Thanks in advance

macfly August 8, 2013 16:25

A loop inside a DEFINE_ADJUST macro would execute at every iteration. Maybe you can define global variables and use them in both DEFINE_ADJUST and DEFINE_DPM_BODY_FORCE macros?

sayan_bose August 9, 2013 14:54

I would definitely try that, and thanks for your suggestion.


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