
Description
You can use DEFINE_CG_MOTION to specify the motion of a particular dynamic zone in ANSYS FLUENT by providing ANSYS FLUENT with the linear and angular velocities at every time step. ANSYS FLUENT uses these velocities to update the node positions on the dynamic zone based on solidbody motion. Note that UDFs that are defined using DEFINE_CG_MOTION can only be executed as compiled UDFs.
Usage
DEFINE_CG_MOTION( name, dt, vel, omega, time, dtime) 
Argument Type  Description 
symbol name  UDF name. 
Dynamic_Thread *dt  Pointer to structure that stores the dynamic mesh 
attributes that you have specified (or that are calculated  
by ANSYS FLUENT).  
real vel[]  Linear velocity. 
real omega[]  Angular velocity. 
real time  Current time. 
real dtime  Time step. 
Function returns  
void  
There are six arguments to DEFINE_CG_MOTION: name, dt, vel, omega, time, and dtime. You supply name, the name of the UDF. dt, vel, omega, time, and dtime are variables that are passed by the ANSYS FLUENT solver to your UDF. The linear and angular velocities are returned to ANSYS FLUENT by overwriting the arrays vel and omega, respectively.
Example
Consider the following example where the linear velocity is computed from a simple force balance on the body in the xdirection such that
(2.61) 
where is velocity, is the force and is the mass of the body. The velocity at time is calculated using an explicit Euler formula as
(2.62) 
/************************************************************ * 1degree of freedom equation of motion (xdirection) * compiled UDF ************************************************************/ #include "udf.h" static real v_prev = 0.0; DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime) { Thread *t; face_t f; real NV_VEC(A); real force, dv; /* 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 pressure force on body by looping through all faces */ force = 0.0; begin_f_loop(f,t) { F_AREA(A,f,t); force += F_P(f,t) * NV_MAG(A); } end_f_loop(f,t) /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv = dtime * force / 50.0; v_prev += dv; Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev, force); /* set xcomponent of velocity */ vel[0] = v_prev; } 
Hooking a Center of Gravity Motion UDF to
ANSYS FLUENT
After the UDF that you have defined using DEFINE_CG_MOTION is compiled (Chapter 5), the name of the argument that you supplied as the first DEFINE macro argument will become visible in the Dynamic Mesh Zones dialog box in ANSYS FLUENT. See Section 6.5.1 for details on how to hook your DEFINE_CG_MOTION UDF to ANSYS FLUENT.