CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Dynamic mesh udf example (http://www.cfd-online.com/Forums/fluent/37913-dynamic-mesh-udf-example.html)

 avant September 15, 2005 15:08

Dynamic mesh udf example

Hi,

Can anyone please post or direct me towards an example udf for dynamic mesh motion Thanks, Avant

 Manoj Kumar September 16, 2005 01:17

Re: Dynamic mesh udf example

Hi

There is an example in fluent tutorial, which uses dynamic mesh. Go through its udf.

Regards,

Manoj

 Manoj Kumar September 16, 2005 01:24

Re: Dynamic mesh udf example

Following udf calculates force acting on a regid body and sets its x-component of velocity. At the end of every time step, the udf is used and the mesh is updated.

#include "udf.h"

static real v_prev = 0.0;

DEFINE_CG_MOTION(block,dt,vel,omega,time,dtime)

face_t f;

real NV_VEC(A);

real force, dv;

/* 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 */

/* 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;

v_prev += dv;

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

/* set x-component of velocity */

vel[0] = v_prev;

}

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