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

UDF Parabolic Inlet Profile for Multiple Inlets

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2021, 07:46
Post UDF Parabolic Inlet Profile for Multiple Inlets
  #1
New Member
 
Luis
Join Date: Dec 2021
Location: Santander
Posts: 6
Rep Power: 4
luisvolumentres is on a distinguished road
Hi!

I'm trying to simulate a water tank which has multiple inlets and applying to them a UDF to specify a parabolic inlet profile. The problem comes while calculating the distance from any point of the inlets surface to its centre because the inlets are not in point (0,0,0). I'm using a 3D version of the 2D example found in Fluent Manual:

/************************************************** *********************/
/* vprofile.c */
/* UDF for specifying steady-state velocity profile boundary condition */
/************************************************** *********************/
#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;
}
end_f_loop(f, thread)
}

I assume that I could change y = x[1] to y = x[1] - x0, being x0 the centre of every inlet. However, since I almost have 200 inlets it would be something very annoying if I do it manually. Could anyone give me a hint for obtaining the centre of each of the inlets automatically so I can easily make it work?

Thank you everybody in advance!
luisvolumentres is offline   Reply With Quote

Old   December 15, 2021, 17:53
Default
  #2
New Member
 
Chris
Join Date: Mar 2021
Posts: 23
Rep Power: 5
cbooks77 is on a distinguished road
You know you can just attach a velocity profile without using a UDF? You can also use expressions. I would look into just using the profile. Solve the fully developed flow in a single inlet separate model. Then take that profile data at the boundary and apply it to all your inlets. Also you are using 3D so you would need a conical velocity inlet as parabolic is 2D. Thats going to be more challenging to implement in a UDF...

https://www.youtube.com/watch?v=DQYlnsAfs5s
cbooks77 is offline   Reply With Quote

Old   December 16, 2021, 03:50
Default
  #3
New Member
 
Luis
Join Date: Dec 2021
Location: Santander
Posts: 6
Rep Power: 4
luisvolumentres is on a distinguished road
Thank you for your reply!

Expressions have the same problem as UDF, you need to know the centre of each inlet in order to have the X,Y and Z coordinates relative to the centre of each inlet, right? I guess the same problem would arise while mapping the inlet with the Velocity Profile since position changes for each inlet. Regarding the conic inlet for 3D case, it is just straight forward to implement it based on the 2D UDF shown in the Fluent UDF Guide and it works properly for a simple geometry (e.g. one pipe).
luisvolumentres is offline   Reply With Quote

Old   December 16, 2021, 05:17
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Something like this might work: calculate the average position in the UDF.



real ysum=0, yavg;
int ycount=0;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
ysum +=y;
++ycount;
}
end_f_loop(f, thread)
}
yavg=ysum/ycount;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1]-yavg;
F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;
}
end_f_loop(f, thread)
}

I did not test it and wrote it on my phone, so typos might be there.

This calculates the average position giving each face the same weight. It's better to make the weight proportional to the area. But if your mesh is not too weird, the error should be very small.
anan12345 and luisvolumentres like this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 21, 2021, 11:52
Smile
  #5
New Member
 
Luis
Join Date: Dec 2021
Location: Santander
Posts: 6
Rep Power: 4
luisvolumentres is on a distinguished road
Quote:
Originally Posted by pakk View Post
Something like this might work: calculate the average position in the UDF.



real ysum=0, yavg;
int ycount=0;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
ysum +=y;
++ycount;
}
end_f_loop(f, thread)
}
yavg=ysum/ycount;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1]-yavg;
F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;
}
end_f_loop(f, thread)
}

I did not test it and wrote it on my phone, so typos might be there.

This calculates the average position giving each face the same weight. It's better to make the weight proportional to the area. But if your mesh is not too weird, the error should be very small.
Hi, thank you for your reply! I have just tried it in a simple geometry with its inlet centre not in [0,0,0] and it worked perfectly! Thank you so much for your help .

Best regards
luisvolumentres is offline   Reply With Quote

Reply

Tags
#fluent, #parabolicprofileinlet, #udf


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
static Pressure profile using udf at velocity inlet vivek123 Fluent UDF and Scheme Programming 0 September 22, 2021 14:44
UDF parabolic velocity profile issue Kenzhia3310 FLUENT 3 April 7, 2020 11:20
UDF Parabolic 2D Velocity Profile Issue chrislyn FLUENT 2 December 11, 2018 12:11
UDF 2D inlet profile Thomashoffmann Fluent UDF and Scheme Programming 3 January 17, 2013 03:38
UDF writing: parabolic profile Kwiaci Fluent UDF and Scheme Programming 11 June 5, 2012 10:13


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