CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   DEFINE_CG_MOTION and pressure force (

Teo Fumagalli April 11, 2008 10:25

DEFINE_CG_MOTION and pressure force
Hello, I want to model a closed channel in 2D with left and right walls moving with a sine function velocity. In the middle of channel there is a rigid body which is supposed to move because of the force exercised by the pressure on its walls. I wrote udf for the walls using DEFINE_CG_MOTION macro and it works fine. I wrote also a udf for the rigid body always with DEFINE_CG_MOTION macro, but it doesn't work. As soon the simulation starts it gives a segmentation violation error. The remeshing strategy is correct, probably the error is in the udf. Can anyone help me to find the mistake if there is one? (After the pressure force is computed, shear force is subtracted. To get the axial velocity I used the drag friction force, because the rigid body should mimic a bubble of air._ Thank you

/************************************************** ********** * 1-degree of freedom equation of motion (x-direction) * compiled UDF ************************************************** **********/ #include "udf.h" static real v_prev = 0.0; static real force = 0.0;

DEFINE_CG_MOTION(drag,dt,vel,omega,time,dtime) { face_t f; Thread *t; real NV_VEC(A);

/* reset velocities */ NV_S(vel, =, 0.0); NV_S(omega, =, 0.0);

if (!Data_Valid_P())


/* compute pressure force on body by looping through all faces */ /* subtract to the presure force the wall shear force */ begin_f_loop(f,t)



force += F_P(f,t) * A[0]+ F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[0];

} end_f_loop(f,t)

/* considering the rigid body a bubble of gas with no mass*/ /* velocity is computed according to the friction drag force F=1/2*rho*Cd*A*u^2 */ /* velocity = force / (6*viscosity* radius) */ /* 0.001 = viscosity, 0.000014 = radius */

v_prev = force/(6*3.412*0.001*0.000014);

/* set x-component of velocity */ vel[0] = v_prev;

All times are GMT -4. The time now is 06:43.