2.6.1.  DEFINE_CG_MOTION

2.6.1.1. 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 solid-body motion.

Note that UDFs that are defined using DEFINE_CG_MOTION can ONLY be executed as compiled UDFs.


Important:  Depending on the mesh smoothing models used and the dynamic mesh setup, ANSYS Fluent can call mesh motion UDFs multiple times during a single time step. Therefore, UDFs must be written so that the specified motion is an absolute function of time or so that the motion is not incremented incorrectly if the UDF is called multiple times. See the Example for a sample UDF.


2.6.1.2. 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.

By default, the motion of the dynamic zone dt is defined in the local reference frame. If you want to specify its rotation and translation in the absolute reference frame, set DT_NEST_LOC_ROT_P(dt) and DT_NEST_LOC_TRAN_P(dt) to FALSE, respectively. The DT_NEST_LOC_ROT_P(dt) function store a Boolean value (TRUE or FALSE) that determines whether the rotation of the dynamic zone dt is specified relative to the local or absolute reference frame. Similarly, the DT_NEST_LOC_TRAN_P(dt) function is used to specify a reference frame for the translation of the dynamic zone dt.

For additional information, see Rigid Body Motion in the Fluent User's Guide.

2.6.1.3. Example

Consider the following example where the linear velocity is computed from a simple force balance on the body in the X direction such that

(2–23)

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–24)

/************************************************************
* 1-degree of freedom equation of motion (x-direction)
* compiled UDF
************************************************************/
#include "udf.h"

static real v_prev = 0.0;
static real time_prev = 0.0;

DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
  Thread *t;
  face_t f;
  real NV_VEC(A);
  real force_x, 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_x = 0.0;
  begin_f_loop(f,t)
    {
      F_AREA(A,f,t);
      force_x += F_P(f,t) * A[0];
    }
  end_f_loop(f,t)
  /* compute change in velocity, dv = F*dt/mass */
  dv = dtime * force_x / 50.0;
  /* motion UDFs can be called multiple times and should not cause
     false velocity updates */
  if (time > (time_prev + EPSILON))
    {
      v_prev += dv;
      time_prev = time;
    }
  Message("time = %f, x_vel = %f, x_force = %f\n", time, v_prev, force_x);
  /* set x-component of velocity */
  vel[0] = v_prev;
}

2.6.1.4. Hooking a Center of Gravity Motion UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_CG_MOTION is compiled (Compiling UDFs), 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 Hooking DEFINE_CG_MOTION UDFs for details on how to hook your DEFINE_CG_MOTION UDF to ANSYS Fluent.


Release 18.2 - © ANSYS, Inc. All rights reserved.