CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   "while" command in UDF (https://www.cfd-online.com/Forums/fluent/33130-while-command-udf.html)

wim vos February 27, 2004 04:30

"while" command in UDF
 
hey you all, i'm modelling a user defined pressure outlet. in my model i have 4 different equations for the pressure (dependent on time). i tried to model it with a 'while' command. fluent compiles my C file but if i try to initialize fluent keeps on working (uses all possible memory of my computer, let it run over the night and still running)

i include my c-file so that u can see what i did. i hope that somebody can give me an answer.

thanks in advance

WIm

#include "udf.h"

DEFINE_PROFILE(outlet_snif1, thread, nv) { face_t f; real t = RP_Get_Real("flow-time");

begin_f_loop (f,thread)

{

do

{

F_PROFILE(f,thread,nv) = 0 * pow(t,0) + 0 * pow(t,1) - 7.615e+012 * pow(t,2) + 1.588e+012 * pow(t,3) - 1.371e+011 * pow(t,5) + 6.346e+009 * pow(t,6) - 1.708e+008 * pow(t,7) + 2.702e+006 * pow(t,8) - 2.383e+004 * pow(t,9) - 1.018 * pow(t,10);

}

while (t <= 5.133333333333333 * pow(10,-2));

do

{

F_PROFILE(f,thread,nv) = - 3.345e+004 * pow(t,0) + 6.08e+004 * pow(t,1) - 4.782e+004 * pow(t,2) + 2.131e+004 * pow(t,3) - 5915 * pow(t,5) + 1057 * pow(t,6) - 121.4 * pow(t,7) + 8.604 * pow(t,8) - 0.3407 * pow(t,9) - 94.82 * pow(t,10);

}

while (t <= 3.336666666666666 * pow(10,-1));

do

{

F_PROFILE(f,thread,nv) = 6.862e+012 * pow(t,0) - 8.426e+012 * pow(t,1) + 0 * pow(t,2) + 3.467e+012 * pow(t,3) + 0 * pow(t,5) - 2.062e+012 * pow(t,6) + 1.332e+012 * pow(t,7) - 3.89e+011 * pow(t,8) + 5.652e+010 * pow(t,9) - 3.326e+009 * pow(t,10);

}

while (t <= 3.843333333333333 * pow(10,-1));

do

{

F_PROFILE(f,thread,nv) = 3.723e+006 * pow(t,0) - 4.643e+006 * pow(t,1) + 0 * pow(t,2) + 0 * pow(t,3) + 4.662e+006 * pow(t,5) - 5.81e+006 * pow(t,6) + 3.217e+006 * pow(t,7) - 9.54e+005 * pow(t,8) + 1.485e+005 * pow(t,9) - 9587 * pow(t,10);

}

while (t > 3.843333333333333 * pow(10,-1));

} end_f_loop (f,thread) }

Ale February 27, 2004 09:58

Re: "while" command in UDF
 
Hi Wim, remember that your UDF is executed before each iteration, and all cycles need to exit before going to the following iteration. If you use the do{}while cycle, checking the value of t, but not changing t in the body of the cycle, if t satisfies the condition once, it will satisfy it again and again, and the program will never exit the cycle.

I think you should replace the do{}while cycle with an if() control

I hope this helps.

Ale


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