CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Iteration Variable! (http://www.cfd-online.com/Forums/fluent/30434-iteration-variable.html)

Ugur October 25, 2002 15:12

Iteration Variable!
 
Hi;

Does anybody know the variable where the current iteration number is stored? I'm trying to code a udf which has to be accessed every 5-10 iterations.

Thanks...

Ugur

Carsten Dehning October 27, 2002 10:02

Re: Iteration Variable!
 
I know that there is no global fluent variable containing the current iteration value. Here is my quick&dirty workaround coded in the UDF's.

/********************************************/

static int my_iter_counter = 0; static int exec_my_udf = 0;

DEFINE_INIT(...) {

my_iter_counter =

exec_my_udf = 0;

... init something else here ... }

/* called after each iteration */ DEFINE_ADJUST(...) {

/*

* switch UDF exec on at each 10th iteration,

* else off, start with on (iteration 0)

*/

exec_my_udf = (my_iter_counter++ % 10) == 0;

... adjust something else here ... }

/* called for each cell/thread.. it depends */ DEFINE_SOURCE/PROPERTY/ETC(...) {

if (!exec_my_udf)

return; /* or return 0 or whatever */

... execute UDF ... }

/********************************************/

This works fine.

With best regards

Carsten Dehning


Ugur October 27, 2002 16:52

Re: Iteration Variable!
 
Thanks for your reply, By the way I have found that the iteration variable is stored in a vector called count2[nres-1]. To use this you can define a variable, such as int itervar=(nres==0)?(1):((int)count2[nres-1]); Thanks


All times are GMT -4. The time now is 07:49.