MR CFD
Oops! You are not logged in.

For watching this lesson you should sign in first, if you don't have an account, you can create one in seconds.

Toggle Lesson List

UDF: Beginner CFD Training Package — Ep 05

CG-Motion Macro: Reciprocating Motion

Lesson
05
Run Time
18m 20s
Published
Aug 19, 2026
Category
UDF
Course Progress
0%
Mark as Complete
Add to Watchlist
About This Lesson

Description

This lesson covers the CG-MOTION macro for prescribing reciprocating motion on a rigid body within ANSYS Fluent's dynamic mesh framework. The test case is a cubic object undergoing reciprocating translation inside a computational domain, chosen to demonstrate how a custom user-defined function can drive complex, prescribed object motion rather than relying on Fluent's built-in motion definitions. The 3D geometry is built in Design Modeler and meshed in ANSYS Meshing with an unstructured grid of 143,423 cells.

Methodology

The simulation uses Fluent's Dynamic Mesh model to deform the mesh around the moving object, with the object itself defined as a rigid body. The reciprocating translation is implemented through a custom velocity function written into the DEFINE_CG_MOTION macro, which is then compiled and loaded into Fluent and linked to the Dynamic Mesh setup so the mesh motion follows the UDF-prescribed velocity at every time step rather than a fixed or externally-solved motion.

Analysis

The results include time-dependent geometry snapshots, the motion path traced by the object, and plots of velocity and position over time. Together these confirm the UDF is driving the reciprocating motion as intended, correctly reversing direction and velocity at each cycle. The approach generalizes directly to applications with prescribed or periodic motion, such as piston engines or industrial mixing equipment, and provides a foundation for extending into coupled fluid-structure interaction, multiple independently-moving objects, or motion patterns that adapt to local flow conditions.