Santu Golder
Subscriber

 

 

Hi 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