-
-
January 11, 2023 at 9:34 pm
Santu Golder
SubscriberHi,
I am doing dynamic mesh for my simulation using UDF. What code can I use in UDF to give the distance that the moving body can travel? I want to limit the distance to be traveled between 0 to 0.25 (m). And it is an oscillation of a solid body.
Following is the equation that is applied to give the motion.
vel = 0.03*sin(1.1416*time/10.);
Santu
-
January 12, 2023 at 10:45 am
Prashanth
Ansys EmployeeHi
DEFINE_CG_MOTION can be used. You can also check a example case in the UDF manual.
-
January 12, 2023 at 5:31 pm
Santu Golder
SubscriberHi Prashanth,
Thank you for your reply. I've coded the equation as follows:
# include "udf.h"
static real velx = 0.0;
DEFINE_CG_MOTION(box,dt,vel,omega,time,dtime)
{
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);velx = 0.01*sin(1.1416*time/10.);
vel[1] = velx;
Message("time = %f, vel[1] = %f\n", time, vel[1]);
}But for giving the limit to move the moving box, which one should I add:
if (!Data_Valid_P())
return;or
any other loop that I need to apply.
-
January 13, 2023 at 12:19 pm
Prashanth
Ansys EmployeeSure, you can use if and else to limit the motion
-
January 17, 2023 at 6:26 pm
Santu Golder
SubscriberHi,
Can you please help me to apply the if and else statement to limit the motion? Mine is not working at all.
Regards
Santu
-
January 18, 2023 at 1:32 pm
Prashanth
Ansys EmployeeHi, Can you check out this dynamic mesh robotic arm tutorial that uses something similar:
-
January 18, 2023 at 8:51 pm
Santu Golder
SubscriberHi Prashant,
I’ve applied the following code for limiting the motion. But it did not work, My motion is sinusoidal and the length is 0 m to 0.2m. I want to limit it to 0.18 m and the box will return its initial position. It is a to and fro motion of piston in a piston chamber.
# include “udf.h”
static real velx = 0.0;
DEFINE_CG_MOTION(box,dt,vel,omega,time,dtime)
{
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);velx = 0.05*sin(3.1416*time/10.);
if (time<=5)
vel[1] = velx;
else
vel[1] = velx;Message(“time = %f, vel[1] = %f\n”, time, vel[1]);
}Regards
Santu
-
- You must be logged in to reply to this topic.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
-
2534
-
2066
-
1285
-
1104
-
459
© 2023 Copyright ANSYS, Inc. All rights reserved.