## Fluids

#### Dynamic Mesh

Subscriber

How to write a UDF for pressure driven flow under dynamic mesh conditions?

Inlet pressure used to push the pig by that i have to find velocity of pig.

Here i have attached picture for your view.

• Karthik R

Hello,

Please refer to the UDF manual for details on how to write the UDF. I generally tend to use an already written UDF from the manual and modify to serve my purpose (rather than starting from scratch).

Btw, what are planning on doing with your UDF? Just curious.

Best Regards,

Karthik

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;

face_t f;

real NV_VEC(A);

real force,force1,force2, dv;

/* reset velocities */

NV_S(vel, =, 0.0);  /* scalar vel[0] = 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[0];

}

end_f_loop(f,t1)

begin_f_loop(f,t2)

{

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

}

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[0] = v_prev;

}

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

• Raef.Kobeissi
Subscriber

Hello,

Why is your UDF very complicated? for transient pressure inlet boundary condition, the UDF is simple. You can also write to file the velocity of the solid object:

Regards