|
|
【答案】应助回帖
感谢参与,应助指数 +1
#include "stdio.h"
#include "udf.h"
#include "mem.h"
#define tank_length 0.435
/****************************************************************2.底部液体接触部分边界条件*/
/***********************************************************************/
/* UDF for boundary temperature condition of wall_bottom */
/************************************************************************/
DEFINE_PROFILE(wall_bottom_temperature,thread,position)
{
face_t f;
begin_f_loop(f,thread)
{
real t=RP_Get_Real("flow-time" ;
F_PROFILE(f,thread,position)=148.8+0.00036*t;
}
end_f_loop(f,thread)
}
/************************************************************************3.上部气体接触部分边界条件*/
/***********************************************************************/
/* UDF for boundary temperature condition of wall_gas */
/**********************************************************************/
DEFINE_PROFILE(wall_gas_temperature,thread,position)
{
face_t f;
begin_f_loop(f,thread)
{
real t=RP_Get_Real("flow-time" ;
F_PROFILE(f,thread,position)=150.8+0.00875*t;
}
end_f_loop(f,thread)
}
/************************************************************************4.柱状段气液变化边界条件*/
/***********************************************************************/
/* UDF for boundary temperature condition of wall_cyli */
/**********************************************************************/
DEFINE_PROFILE(wall_cyli_temperature,thread,position)
{
real x[ND_ND]; /* this will hold the position vector */
real y, h;
real exp=1e-5;
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y=x[0];
if(y<0.092)
F_PROFILE(f,thread,position)=-156*(y-0.092)+148.8;
else
if(y<0.142)
F_PROFILE(f,thread,position)=140*(y-0.092)+141;
else
if(y<0.192)
F_PROFILE(f,thread,position)=-340*(y-0.142)+148;
else
if(y<0.242)
F_PROFILE(f,thread,position)=-160*(y-0.192)+131;
else
F_PROFILE(f,thread,position)=347.5*(y-0.242)+123;
}
end_f_loop(f,thread)
}
/***********************************************************************5.初始化温度场*/
/* UDF for initializing flow field variables */
/***********************************************************************/
DEFINE_INIT(my_init_func,domain)
{
cell_t c;
Thread *t;
real x[ND_ND];
/* loop over all cell threads in the domain */
thread_loop_c(t,domain)
if (FLUID_THREAD_P(t))
{
/* loop over all cells in fluid */
begin_c_loop_all(c,t)
{
C_CENTROID(x,c,t);
if (x[0]<0.297)
C_T(c,t) = 77.35;
C_P(c,t) = C_R(c,t)*9.81*(tank_length-x[0]);
else
C_T(c,t)=606.5*(x[0]-0.297)+77.35;
C_P(c,t) = C_R(c,t)*9.81*(tank_length-x[0]);
}
end_c_loop_all(c,t)
}
else
{
/* loop over all cells in solid */
begin_c_loop (c,t)
{
C_CENTROID(x,c,t);
if ( x[0] < xlg )
{
C_T(c,t) = 77.35;
}
else
{
C_T(c,t)=606.5*(x[0]-0.297)+77.35;
}
}
end_c_loop (c,t)
}
}
/**************************************************************/
/* UDF for boundary thermal condition of outlet */
/**************************************************************/
DEFINE_PROFILE(backflow_temp,thread,index)
{
face_t ft;
cell_t c0;
Thread *tc0;
begin_f_loop(ft,thread)
{
c0 = F_C0(ft,thread);
tc0 = THREAD_T0(thread);
F_PROFILE(ft,thread,index) = C_T(c0,tc0);
}
end_f_loop(ft,thread)
}
/**************************************************************/
/* UDF for boundary pressure condition of outlet */
/**************************************************************/
DEFINE_PROFILE(outflow_pres,thread,index)
{
face_t ft;
cell_t c0;
Thread *tc0;
real pout;
begin_f_loop(ft,thread)
{
c0 = F_C0(ft,thread);
tc0 = THREAD_T0(thread);
pout = C_P(c0,tc0);
if (pout < 0.0)
{
F_PROFILE(ft,thread,index) = C_P(c0,tc0);
}
}
end_f_loop(ft,thread)
}
参照这个程序即可 |
|