level 3
3、采用DEFINE_CG_MOTION的形式定义阀芯运动,具体UDF如下:
# include "udf.h"
# include "dynamesh_tools.h"
# define DEBUG 1
# define NO_OF_VALVES 9
# define NO_OF_ZONES 15
/*************************** User Input Starts *****************************/
# define INITIAL_LIFT -28e-3
static int valveid[NO_OF_VALVES][NO_OF_ZONES]={{190,129,135,141,175,168,162,176,149, -1}};
static real lift_min[NO_OF_VALVES]={0.0272};
static real lift_max[NO_OF_VALVES]={0.034};
static real mass[NO_OF_VALVES]={0.025};
static real stiffness[NO_OF_VALVES]={1500};
static real stretch_at_closed[NO_OF_VALVES]={0};
static real rest_conts[NO_OF_VALVES]={0};
static real current_vel_mag[NO_OF_VALVES]={0};
/*************************** User Input Ends *******************************/
static real axis[NO_OF_VALVES][ND_ND]={{0, 0, 1}}; /* normalized */
static real r_rp_closed[NO_OF_VALVES][ND_ND]={{0,0,0}};
static real cur_r_rp[NO_OF_VALVES][ND_ND]={{0, 0,INITIAL_LIFT}};
static real previous_time[NO_OF_VALVES]={0};
static void f_valve(int valveNo, void *dt, real *cg_vel, real *cg_omega, real time, real dtime)
{
#if !RP_HOST
real tmp[ND_ND], dv, current_vel[ND_ND], CG[ND_ND], force[3], moment[3], stretch;
real aero_force[ND_ND], aero_force_axis, spring_force, net_force,
r_rp_new[NO_OF_VALVES][ND_ND];
int i;
Thread * tf;
Domain * domain;
/******************************************************************/
static real cg_vel_saved[NO_OF_VALVES][ND_ND];
/******************************************************************/
/* Do the calculation if the new time step */
if(fabs(previous_time[valveNo]-time)>0.2*dtime)
{
/* reset velocities */
NV_S (cg_vel, =, 0.0);
/* Check to see if there is data */
if (!Data_Valid_P ())
{
Message0("\n\nNo data->No mesh motion!!!\n\n");
return;
}
2016年09月29日 08点09分