CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF error CG Motion (https://www.cfd-online.com/Forums/fluent/40269-udf-error-cg-motion.html)

Alex March 22, 2006 17:40

UDF error CG Motion
 
Hi, I just wrote a UDF code to describe motion of an airfoil in pitch an plunge. When reading the case file in fluent I get an error saying there is a "SEGMENTATION ERROR".

This happens after I change the UDF file name within the .cas file. eg. (udf/filename "fabio.c") -> within my .cas file.

I think I need to do this so the UDF file is recognized in the .cas file after opening it.

Please correct me if I'm wrong.

This is my UDF file. I'm not sure where the mistake is.

/************************************************** ********** * * Equations of motion to describe an airfoil in pitch (omega = along z-axis) and plunge (vel = y-dir) compiled UDF * ************************************************** **********/ #include "udf.h"

static real v_prev = 0.0;

static real omega_prev = 0.0;

DEFINE_CG_MOTION(piston, dt, vel, omega, time, dtime) { Thread *t; face_t f; real NV_VEC (A); real force, dv, om, f, domega, delta;

f= 0.5; om=2*3.14*f; delta =3.14/2;

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

if (!Data_Valid_P ())

return;

/* get the thread pointer for which this motion is defined */ t = DT_THREAD (dt);

/* compute pressure force on body by looping through all faces */ force = 0.0; begin_f_loop (f, t)

{

F_AREA (A, f, t);

force += F_P (f, t) * NV_MAG (A);

} end_f_loop (f, t)

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

velocity update using explicit Euler formula */ /* dv = dtime * force / 50.0; */

dv=om*cos(om*dtime);

domega=om*cos(om*dtime+delta);

v_prev += dv;

omega_prev +=domega;

Message ("time = %f, y_vel = %f, force = %f, omega=%f\n", time, v_prev, force, omega_prev);

/* set x-component of velocity */ vel[1] = v_prev; omega[2] =omega_prev; }

Could someone please comment if you see a flaw with the code?

Thank you

Alex


All times are GMT -4. The time now is 03:29.