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

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

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 19, 2012, 17:35
Post USING IF statement in a UDF for defining Velocity profile at Inlet
  #1
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 17
amir2920 is on a distinguished road
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"
DEFINE_PROFILE(inlet_x_velocity, thread, position)
{

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



begin_f_loop(f,thread)
{
F_CENTROID(x, f, thread);
y = x[1];

If (y<0.003)
v= -228.*y+11.6;
else
v=-10200.*y+41.52
F_PROFILE(f, thread, position)=v;
}
end_f_loop(f, thread)

}
amir2920 is offline   Reply With Quote

Old   July 19, 2012, 18:04
Default
  #2
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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.
flotus1 is offline   Reply With Quote

Old   July 19, 2012, 18:09
Default
  #3
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 17
amir2920 is on a distinguished road
Quote:
Originally Posted by flotus1 View Post
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.
Thank you for your reply,

I tried that before, did not work.

It gave me an error indicating that the undeclared variable in IF statement.
Does it underestand the y variable in If statement?
amir2920 is offline   Reply With Quote

Old   May 24, 2013, 00:46
Default
  #4
AGP
Member
 
Anonymous
Join Date: Apr 2013
Posts: 34
Rep Power: 13
AGP is on a distinguished road
Hey Amir, I am facing the same problem. My UDF doesn't understand the if statement. How did you fix your problem?
AGP is offline   Reply With Quote

Reply


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
UDF paraboloid velocity inlet rosco FLUENT 10 June 2, 2017 09:01
unsteady inlet velocity udf jill FLUENT 8 February 10, 2015 07:04
UDF for velocity profile egge24 Fluent UDF and Scheme Programming 0 April 4, 2012 20:57
Inlet Velocity Profile BC - Floating Point exception during solution initialization Janshi STAR-CCM+ 4 March 14, 2012 11:21
UDF parallel velocity inlet profile Armengol FLUENT 3 September 30, 2009 16:08


All times are GMT -4. The time now is 16:50.