TAGGED: ansys-fluent, define_grid_motion, udf, udferror
-
-
July 11, 2025 at 6:39 pm
jdch232
SubscriberHello,
I'm attempting to model a flexible flat plate using using a UDF with the DEFINE_GRID_MOTION macro in Fluent 2025 R1 student through Workbench. I'm new to using UDFs, though I have gotten some working. I'm defining a flexible plate as one that alternates between flat and bulging outwards in several peaks over time.
I'm using the following equation for y-velocity: Vy = (5pi/33) *Â (sin{2pi *Â t - 1.5} + 1) * sin{10000pi * x}
This results in a plate alternating between flat at 0s, 1s, 2s, ... and a flexed at 0.5s, 1.5, 2.5s, ..., as shown below.
I'm using the following c code:
#include "udf.h"DEFINE_GRID_MOTION(flexible_wall_velocity, domain, dt, time, dtime){ Thread *t; face_t f; Node *v; real NV_VEC(velocity); thread_loop_c(t, domain) {   // Loop across faces in wall   begin_f_loop(f, t)   {    // Loop across nodes of face    f_node_loop(f, t, v)    {     // Current node's coordinates     real x_coord = NODE_X(v);     real y_coord = NODE_Y(v);     // Calculate velocity based on x_coord and time     velocity[0] = 0;     velocity[1] = (5 * 3.14159 / 33) * (sin(2 * 3.14159 * time - 1.5) + 1) * (sin(1000 * 3.14159 * x_coord));     // Update node's position from calculated velocity     NODE_X(v) += velocity[0] * dtime;     NODE_Y(v) += velocity[1] * dtime;    }   }   end_f_loop(f, t)  } }When I compile the code in Fluent I get this warning:Â
"warning: ordered comparison between pointer and integer ('Node *' (aka 'struct _tg_node_struct *') and 'int')
      f_node_loop(f, t, v)
      ^~~~~~~~~~~~~~~~~~~~"
I've looked into this and found it's saying I'm comparing a pointer variable and an integer. Though I'm having trouble seeing where.
Then when I create the dynamic mesh on the plate, I get this warning:
"Warning: incorrect cg motion UDF flexible_wall_velocity::libudf on zone 10 (assuming no motion)"
This confuses me as I'm not using the CG Motion macro. Does anyone have any advice or direction I could take?
-
July 17, 2025 at 3:16 pm
Mark O
Ansys EmployeePlease see the example for DEFINE_GRID_MOTION in the Fluent Customization manual. It is not f_node_loop(f, t, v). It is
int n;
f_node_loop(f,t,n)
{
 v = F_NODE(f,t,n);
}
Â
-
July 17, 2025 at 3:46 pm
jdch232
SubscriberYes I was able to get it working. For anyone who might find it helpful, this is the code that ended up working:
Â
#include "udf.h"#include "math.h"#define PI 3.14159DEFINE_GRID_MOTION(dynamic_wall_motion, domain, dt, time, dtime){Â Â Thread *thread = DT_THREAD(dt);Â Â face_t f;Â Â Node *v;Â Â int n;Â Â real x, y, dy;Â Â begin_f_loop(f, thread)Â Â {Â Â Â Â f_node_loop(f, thread, n)Â Â Â Â {Â Â Â Â Â Â v = F_NODE(f, thread, n);Â Â Â Â Â Â if (NODE_POS_NEED_UPDATE(v))Â Â Â Â Â Â {Â Â Â Â Â Â Â Â x = NODE_X(v);Â Â Â Â Â Â Â Â y = NODE_Y(v);Â Â Â Â Â Â Â Â dy = (1.0 / 80000.0) * (sin((20000000.0 / 3.0) * PI * time - 1.5) + 1) * -cos(10000.0 * PI * x);Â Â Â Â Â Â Â Â NODE_Y(v) = dy;Â Â Â Â Â Â Â Â NODE_POS_UPDATED(v);Â Â Â Â Â Â }Â Â Â Â }Â Â }Â Â end_f_loop(f, thread)}Just plug that into the dynamic mesh and apply it to whatever boundary you're moving
-
- You must be logged in to reply to this topic.
-
3492
-
1057
-
1051
-
965
-
942
© 2025 Copyright ANSYS, Inc. All rights reserved.