|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
中间我尝试用message输出一些参数的信息,但是在TUI窗口上什么都没有显示,不知道问题究竟出在什么地方,麻烦大家帮我看看,谢谢大家。
下面是写的udf:
#include "udf.h"
#include "dynamesh_tools.h"
/* velocities */
static real v_invalve1 = 0.0;
static real v_exvalve1 = 0.0;
/* displacement */
static real s_invalve1 = 0.0;
static real s_exvalve1 = 0.0;
static real lift = -0.0015;
DEFINE_CG_MOTION(invalve1,dt,vel,omega,time,dtime)
{
Thread *t1, *t2;
face_t f;
real NV_VEC(A);
real force, dv, a, ds;
Domain * domain;
int zone_id1=81;
int zone_id2=91;
/* reset velocities */
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);
if (!Data_Valid_P())
return;
/* get the thread pointer for which this motion is defined */
domain=THREAD_DOMAIN(DT_THREAD(dt));
t1=Lookup_Thread(domain,zone_id1);
t2=Lookup_Thread(domain,zone_id2);
/* compute pressure force on body by looping through all faces */
force = 0.0;
begin_f_loop(f,t1)
{
F_AREA(A,f,t1);
force += F_P(f,t1) * A[1];
}
end_f_loop(f,t1)
begin_f_loop(f,t2)
{
F_AREA(A,f,t2);
force += F_P(f,t2) * A[1];
}
end_f_loop(f,t2)
/* compute change in velocity, i.e., dv = F * dt / mass
velocity update using explicit Euler formula */
a=force/0.1089;
ds=0.5*a*dtime*dtime;
if(s_invalve1+ds<=lift)
{
v_invalve1=(lift-s_invalve1)/dtime;
s_invalve1=lift;
}
else if(s_invalve1+ds>=0)
{
v_invalve1=(0-s_invalve1)/dtime;
s_invalve1=0;
}
else
{
dv = dtime * a;
v_invalve1 += dv;
s_invalve1 += ds;
}
Message ("time = %f, y_vel = %f, force = %f\n", time, v_invalve1, force);
/* set y-component of velocity */
vel[1] = v_invalve1;
} |
|