|
楼主 |
发表于 2009-2-21 16:10:14
|
显示全部楼层
具体代码如下:
#include "stdio.h"
#include "udf.h"
/*#define PI=3.1415926*/
#define A=0.02
#define omegal 2*3.1415926*2.0
/****************************************
compiled UDF for 2-degree of freedem equation of motion
****************************************/
/*static real o_prev=0.0;*/
DEFINE_CG_MOTION(valve, dt, vel, omega, time, dtime)
{
thread *t;
face_t f;
real dv_y;
/*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*/
t=DT_THREAD(dt);
/*compute change in velocity*/
v_y_prev=omegal*A*cos(omegal*time);
/*message("time=%f,omega=%f\n",time,o_prev);*/
/*set y-component of velocity*/
vel[1]=v_y_prev;
} |
|