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

Looping inside a UDF

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2013, 15:29
Default Looping inside a UDF
  #1
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 12
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, 16:02
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
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 13:19.
macfly is offline   Reply With Quote

Old   August 8, 2013, 17:21
Default
  #3
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 12
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, 17:25
Default
  #4
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
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, 15:54
Default
  #5
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 12
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 Search this Thread
Search this Thread:

Advanced Search
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 Off
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 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


All times are GMT -4. The time now is 15:05.