CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF programming problem (https://www.cfd-online.com/Forums/fluent/29678-udf-programming-problem.html)

 Christian April 25, 2002 08:46

UDF programming problem

Hello everybody!

I have to use an if-statement within the user-defined-function for turbulent viscosity. The code is as follows:

DEFINE_TURBULENT_VISCOSITY(cabot_mu_t, c, t)

{

real mu_t;

real D_y;

real utau;

real rho = C_R(c, t);

real yplus;

real mu_lam = C_MU_L(c, t);

real uzz = mu_lam * C_DWDY(c, t);

mu_t = C_MU_T(c, t);

if (t == WANDNAEHE1)

{

yplus = zgrid / mu_lam * SQR (uzz) * rho;

if (yplus >= 1)

{

utau = SQR(uzz/rho);

D_y = (1-exp(-(yplus/17))) * (1-exp(-(yplus/17)));

mu_t = ((0.42 * zgrid) * utau * D_y);

}

}

return mu_t;

}

The fluid zone with ID=8 is defined to consist of only wall-neighboring cells. There are no problems during the compilation process, but the if-statement does not work. My question is as follows:

Is it allowed to use thread-definitions in if statements? And why the hell does Fluent not execute the computation for mu_t although some of the cells in thread t have to be in thread WANDNAEHE1, too.

All not variables that are not declared within this exerpt are declared "globally".

If anybody knows to help me I would be very grateful!

Chrsitian

 Greg Perkins April 25, 2002 18:58

Re: UDF programming problem

This looks like a basic oversight.

I can't see any definition for the value of the variable zgrid. Its likely that this will be initialised to zero and thus you'll never have a condition that yplus >= 1, hence you'll never set mu_t using your own code.

Greg

 Johnix April 25, 2002 19:07

Re: UDF programming problem

Hi,

Are you using Fluent 6.0? I have only used 5.5 so far. I am not sure whether there is such a macro, DEFINE_TURBULENT_VISCOSITY, maybe different names.

Anyway, I think there is an obvious problem in your code, i.e. where the value of "domain" comes from since "domain" is not in the arguments list of this function?

Maybe you can statically(globally) define a var to send value to "domain" ...

Cheers

 Christian April 26, 2002 04:08

Re: UDF programming problem

Hello and thanks for your help!

As I said in the posting all variables that are not defined in this excerpt are defined before in the UDF. so that could not have been the problem.

As I can say by now there is no error within the UDF, it seemed to have been an error in the Fluent case file. I managed to fix it but I have no explanation how i occurred. Anyway, thanks again!

Christian

@Johnix - I am using Fluent 6.0 but I think the DEFINE_TURBULENT_VISCOSITY makro existed in Fluent 5, too.

 All times are GMT -4. The time now is 01:11.