 gowthamdada
Subscriber

/************************************************************

* compiled UDF

************************************************************/

#include "udf.h"

static real v_prev = 0.0;

static real time_prev = 0.0;

DEFINE_CG_MOTION(pig,dt1,dt2,vel,time,dtime)

{

Domain *d;

d = Get_Domain(1);

int ID1 = 16; int ID2 = 17;

t1 = Lookup_Thread(d, ID1);

t2 = Lookup_Thread(d, ID2);

face_t f;

real NV_VEC(A);

real force,force1,force2, dv;

/* reset velocities */

NV_S(vel, =, 0.0);  /* scalar vel = 0.0*/

if (!Data_Valid_P())

return;

/* get the thread pointer for which this motion is defined

/* compute pressure force on body by looping through all faces */

force = 0.0;

force1=0.0;

force2=0.0;

/*Fc = (2*3.14*5*0.25*10106000*0.3)/(1-0.33);*/ /*contact force= 2*pi*lp*del*E*mu/(1-nu) */

begin_f_loop(f,t1)

{

F_AREA(A,f,t1);

force1 += F_P(f,t1) * A;

}

end_f_loop(f,t1)

begin_f_loop(f,t2)

{

force2 += F_P(f,t2) * A;

}

end_f_loop(f,t1)

force = force1-force2;

/* compute change in velocity, i.e., dv = F * dt / mass - Fc*dt /mass

velocity update using explicit Euler formula */

dv = (time * force / 50.0);/*- (Fc*time / 50.0);*/

if (time > (time_prev + EPSILON))

{

v_prev += dv;

time_prev = time;

}

Message ("time = %f, x_vel = %f, force = %fn", time,  v_prev,force);

/* set x-component of velocity */

vel = v_prev;

}

this is what i tried... but i cant able to pick results.. whats problem on this 