CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   SOLUTION : Cg_motion UDF for a oscillating body (http://www.cfd-online.com/Forums/fluent-udf/85891-solution-cg_motion-udf-oscillating-body.html)

Atze March 9, 2011 06:02

SOLUTION : Cg_motion UDF for a oscillating body
 
Hope it can help someone :D

/* in this example a cilynder with CG=(0,0) in loaded by its own wake. A spring of K=15 keeps it in position*/

#include "udf.h"
#include "dynamesh_tools.h"

DEFINE_CG_MOTION(oscillazione,dt,vel,omega,time,dt ime)
{

real x[ND_ND];
Thread *t;
face_t f;
real A[ND_ND];
real Ft,Fel, dv;
real Keq= 15;
real m = 0.25;
real s;
real force=0;
real v_prev=0;

t = DT_THREAD(dt);

s=DT_CG(dt)[1];

begin_f_loop(f,t)
{
F_AREA(A,f,t);
force += F_P(f,t) * A[1];
}
end_f_loop(f,t)

Fel=-Keq*s;

Ft=force+Fel;
dv=(Ft/m)*dtime;

vel[1] = DT_VEL_CG(dt)[1]+dv;

}


All times are GMT -4. The time now is 14:40.