CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   USING IF statement in a UDF for defining Velocity profile at Inlet (https://www.cfd-online.com/Forums/fluent-udf/104977-using-if-statement-udf-defining-velocity-profile-inlet.html)

 amir2920 July 19, 2012 16:35

USING IF statement in a UDF for defining Velocity profile at Inlet

Hi,

I want to define a velocity profile at my inlet boundary condition. This is my UDF which is working for parabolic velocity, but I want to add a function for y<0.003 and another one for y>0.004, so I need to define and if statement. but UDF does not underestand y in the line (If y<0.003).
How could I define y in my IF statement?
Thanks.

#include "udf.h"
{

real x[ND_ND];
real y, v;
face_t f;

{
y = x[1];

If (y<0.003)
v= -228.*y+11.6;
else
v=-10200.*y+41.52
}

}

 flotus1 July 19, 2012 17:04

Very strange. I can't see any error.

But instead of assigning the value of x[1] to the variable y, you could try using x[1] directly in the if-statement and the equation.

 amir2920 July 19, 2012 17:09

Quote:
 Originally Posted by flotus1 (Post 372476) Very strange. I can't see any error. But instead of assigning the value of x[1] to the variable y, you could try using x[1] directly in the if-statement and the equation.