CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

Looping inside a UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 7, 2013, 14:29
Default Looping inside a UDF
  #1
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 4
sayan_bose is on a distinguished road
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.
sayan_bose is offline   Reply With Quote

Old   August 7, 2013, 15:02
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 8
macfly is on a distinguished road
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 12:19.
macfly is offline   Reply With Quote

Old   August 8, 2013, 16:21
Default
  #3
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 4
sayan_bose is on a distinguished road
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
sayan_bose is offline   Reply With Quote

Old   August 8, 2013, 16:25
Default
  #4
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 8
macfly is on a distinguished road
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?
macfly is offline   Reply With Quote

Old   August 9, 2013, 14:54
Default
  #5
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 4
sayan_bose is on a distinguished road
I would definitely try that, and thanks for your suggestion.
sayan_bose is offline   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
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 10:13
how to use TUI commands inside UDF macros??? Giacomo de Renzi FLUENT 1 May 27, 2008 05:06
DEFINE_GEOM UDF Problems Pat FLUENT 0 August 14, 2003 13:16
UDF for looping over nodes in cells. Malcolm Wallace FLUENT 3 July 3, 2000 09:22


All times are GMT -4. The time now is 21:41.