|
[Sponsors] |
August 7, 2013, 15:29 |
Looping inside a UDF
|
#1 |
New Member
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 13 |
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. |
|
August 7, 2013, 16:02 |
|
#2 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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); } } Last edited by macfly; August 8, 2013 at 13:19. |
|
August 8, 2013, 17:21 |
|
#3 |
New Member
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 13 |
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 |
|
August 8, 2013, 17:25 |
|
#4 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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?
|
|
August 9, 2013, 15:54 |
|
#5 |
New Member
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 13 |
I would definitely try that, and thanks for your suggestion.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Drag coefficient, DPM. | jorge poyatos | FLUENT | 14 | January 20, 2012 14:41 |
looping UDF in given direction | ak6g08 | Fluent UDF and Scheme Programming | 0 | September 10, 2009 11:13 |
how to use TUI commands inside UDF macros??? | Giacomo de Renzi | FLUENT | 1 | May 27, 2008 06:06 |
DEFINE_GEOM UDF Problems | Pat | FLUENT | 0 | August 14, 2003 14:16 |
UDF for looping over nodes in cells. | Malcolm Wallace | FLUENT | 3 | July 3, 2000 10:22 |