CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Define velocity profile for cavity (https://www.cfd-online.com/Forums/fluent-udf/128138-define-velocity-profile-cavity.html)

arriftou January 4, 2014 15:28

Define velocity profile for cavity
 
Hi
I m trying to write a UDF for a velocity profile for a cavity problem. The velocity profile is only in the horizontal direction(x direction) like : =-4340.4Z2+8608.2Z-4267 (see figure attached)
But im new in udf programming
I was found some examples in fluent tutorial like this
/************************************************** ***********************/
/* udfexample.c */
/* UDF for specifying a steady-state velocity profile boundary condition */
/************************************************** ***********************/

#include "udf.h"


DEFINE_PROFILE(inlet_x_velocity, thread, index)
{
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, index) = 20. - y*y/(.0745*.0745)*20.;
}
end_f_loop(f, thread)
}

But must I applic this code simply?
Please can anyone help me?

shuai_manlou January 4, 2014 21:24

Where is the attached figure ?
What is the Z means ? If it means the coordinate in the z-axis direction, then you can write your own udf similar to the example. If you have any problem, I can help you.

arriftou January 6, 2014 10:38

velocity profile _file attached missed?
 
1 Attachment(s)
thank you shuai ,
1-about attached figure i dont now i try to do it again
2-about the z coordinate : no sorry i was wrong its the y direction,The velocity profile is only in the horizontal direction(x direction) like:
u (x=0; 0 < z< W ; 1-h/H <y<1)=-4340.4y2+8608.2y-4267 (see file:cavity.docx attached),
thank u in advance

shuai_manlou January 6, 2014 19:00

#include "udf.h"

DEFINE_PROFILE(velocity_inlet, thread, index)
{
real x[ND_ND]; /* this will hold the position vector */
real y, h;
real H = 20; /* the height H, for example */
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);

y = x[1];
h = (H-y)/H;

F_PROFILE(f, thread, index) = -4340.4*h*h+8608.2*h-4267.;
}
end_f_loop(f, thread)
}

You may try my code

arriftou January 7, 2014 12:32

thank, u i will try it and reply to u

arriftou February 4, 2014 09:21

inlet profile
 
1 Attachment(s)
i tested your example but didnt work ,i dnt now why

I want to test the tutorial provided by fluent about: Example 2 - Velocity, Turbulent Kinetic Energy, and Turbulent Dissipation Rate Profiles in 2D configuration, to my case which is a cavity with an inlet an outlet vent,
My configuration is attached
Please help


/************************************************** ********************
Concatenated UDFs for fully-developed turbulent inlet profiles
************************************************** *********************/
#include "udf.h"
#define YMIN 0.0 /* constants */
#define YMAX 0.4064
#define UMEAN 1.0
#define B 1./7.
#define DELOVRH 0.5
#define VISC 1.7894e-05
#define CMU 0.09
#define VKC 0.41
/* profile for x-velocity */
DEFINE_PROFILE(x_velocity,t,i)
{
real y, del, h, x[ND_ND], ufree; /* variable declarations */
face_t f;
h = YMAX - YMIN;
del = DELOVRH*h;
ufree = UMEAN*(B+1.);
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[1];
if (y <= del)
F_PROFILE(f,t,i) = ufree*pow(y/del,B);
else
F_PROFILE(f,t,i) = ufree*pow((h-y)/del,B);
}
end_f_loop(f,t)
}
/* profile for kinetic energy */
DEFINE_PROFILE(k_profile,t,i)
{
real y, del, h, ufree, x[ND_ND];
real ff, utau, knw, kinf;
face_t f;
h = YMAX - YMIN;
del = DELOVRH*h;
ufree = UMEAN*(B+1.);
ff = 0.045/pow(ufree*del/VISC,0.25);
utau=sqrt(ff*pow(ufree,2.)/2.0);
knw=pow(utau,2.)/sqrt(CMU);
kinf=0.002*pow(ufree,2.);
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y=x[1];
if (y <= del)
F_PROFILE(f,t,i)=knw+y/del*(kinf-knw);
else
F_PROFILE(f,t,i)=knw+(h-y)/del*(kinf-knw);
}
end_f_loop(f,t)
}
/* profile for dissipation rate */
DEFINE_PROFILE(dissip_profile,t,i)
{
real y, x[ND_ND], del, h, ufree;
real ff, utau, knw, kinf;
real mix, kay;
face_t f;
h = YMAX - YMIN;
del = DELOVRH*h;
ufree = UMEAN*(B+1.);
ff = 0.045/pow(ufree*del/VISC,0.25);
utau=sqrt(ff*pow(ufree,2.)/2.0);
knw=pow(utau,2.)/sqrt(CMU);
kinf=0.002*pow(ufree,2.);
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y=x[1];
if (y <= del)
kay=knw+y/del*(kinf-knw);
else
kay=knw+(h-y)/del*(kinf-knw);
if (VKC*y < 0.085*del)
mix = VKC*y;
else
mix = 0.085*del;
F_PROFILE(f,t,i)=pow(CMU,0.75)*pow(kay,1.5)/mix;
}
end_f_loop(f,t)
}

anhvulee September 21, 2023 03:23

Hi,
I'm trying to create the UDF based on the examples above. Please elaborate to me about this functions below:
h = YMAX - YMIN;
del = DELOVRH*h;
ufree = UMEAN*(B+1.);
ff = 0.045/pow(ufree*del/VISC,0.25)

What is the meaning of "h", "del", "ff", "DELOVRH" ?

Thank you so much


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