CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Interpreted UDF (https://www.cfd-online.com/Forums/fluent/34502-interpreted-udf.html)

Bikash August 28, 2004 15:40

Interpreted UDF
 
hi

i am trying to use UDF for two different temperature boundary conditons varying with time. one is at the inlet and other one is for ambient air. i have two different equations guiding the temperature. when i compile the udf i get only one udf while defining the boundary conditions. the last one compiled overlaps the previous one, so i cannot define two different boundary condition using the UDF. i used different name while defining the macros, but it didnt work.

i would appreciate any help and suggestions

thank you bikash

Abraham August 29, 2004 01:57

Re: Interpreted UDF
 
Yo have to use a multiple UDF. Take the two codes and put in the same file, after compiled.

When you compiled the file, you will have two UDF for your case.

Bikash August 30, 2004 03:12

Re: Interpreted UDF
 
hi abraham,

well thanks for your help. can you give me more details about how to put two codes in the same file? i really dont know how to put two codes in the same file and compile. i really appreciate your help

thank you bikash

Mahesh Masurkar August 30, 2004 13:08

Re: Interpreted UDF
 
#include "udf.h"

define_profile(temp1...) { } define_profile(temp2...) { }

Then save the file and compile the UDF. ( interrupted).

Mahesh

Abraham August 30, 2004 13:43

Re: Interpreted UDF
 
The following code is of the fluent userīs manual

Example 2 In the following example, DEFINE PROFILE is used to generate pro les for the x velocity, turbulent kinetic energy, and dissipation rate, respectively, for a 2D fully-developed duct flow. Three separate UDFs named x velocity, k profile, and dissip profile are de ned. These functions are concatenated in a single C source le which can be executed as interpreted or compiled in FLUENT. The 1/7th power law is used to specify the x velocity component: vx = vx;free y  1=7 A fully-developed pro le occurs when  is one-half the duct height. In this example, the mean x velocity is prescribed and the peak (free-stream) velocity is determined by averaging across the channel. The turbulent kinetic energy is assumed to vary linearly from a near-wall value of knw = u2  qC to a free-stream value of kinf = 0:002u2 free The dissipation rate is given by  = C3=4  (k3=2) ` where the mixing length ` is the minimum of y and 0.085. ( is the von Karman constant = 0.41.) The friction velocity and wall shear take the forms u = qw= w = fu2 free 2 The friction factor is estimated from the Blasius equation: f = 0:045 ufree  !?1=4 4-28 c Fluent Inc. December 3, 2001 4.3 Model-Speci c DEFINE Macros /************************************************** ********************/ /* 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 */ c Fluent Inc. December 3, 2001 4-29 DEFINE Macros 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); 4-30 c Fluent Inc. December 3, 2001 4.3 Model-Speci c DEFINE Macros 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) } c Fluent Inc. December 3, 2001 4-31

Abraham August 30, 2004 13:49

Re: Interpreted UDF better
 
Example 2

/**************************************************/

/* 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)

}

Bikash August 30, 2004 20:21

Re: Interpreted UDF better
 
hi

thanks a lot for your help. i will try to use the ideas. i'll get back to you guys if i get any trouble.

i really appreciate your help abraham.


Bikash August 31, 2004 12:29

Re: Interpreted UDF better
 
hi abraham,

i followed the example that you gave me for concatenated udfs.

i get syntax error on the line when i add the second udf in the same code file.

i checked everything but its not working, it works if i take the second udf out and just compile single udf.

may be you can suggest me something.

i respect your time and greatly appreciate your help

thankyou

bikash

-------------------------------------------------------------------------------------------------------------------------------------- #include "udf.h"

DEFINE_PROFILE(unsteady_velocity1, thread, position) { face_t f;

begin_f_loop(f, thread)

{

real t = RP_Get_Real("flow-time");

F_PROFILE(f, thread, position) = 20. + 5.0*sin(10.*t);

} end_f_loop(f, thread) }*****************

DEFINE_PROFILE(unsteady_velocity2, thread, position) { face_t f;

begin_f_loop(f, thread)

{

real t = RP_Get_Real("flow-time");

F_PROFILE(f, thread, position) = 20. + 5.0*sin(10.*t);

} end_f_loop(f, thread) }

My udf is pretty much similar to this, i followed the above syntax. i couldnt get access to my program now, cause im in the library. i get error on that line *********************


bikash September 1, 2004 02:30

Re: Interpreted UDF better
 
hi abraham

it worked the way you told me.

thanks a lot

bikash

msbhatti123 April 19, 2016 08:53

Delovrh meaning
 
Hi all,

Could you please let me know, what does DELOVRH means. and how they are doing del= DELOVRH*h. in this profile generation, can i use log law instead of power law? is it makes any difference.thanks

BINAY BHUSHAN BORA December 3, 2019 00:52

Its urgent
 
hi can you please elaborate the meaning of YMIN,YMAX,UMEAN,B,DELOVRH,CMU,VKC.PLEASE HELP ME ANYBODY.


All times are GMT -4. The time now is 21:38.