- **Fluent UDF and Scheme Programming**
(*https://www.cfd-online.com/Forums/fluent-udf/*)

- - **problem of dynamic mesh for a piston model**
(*https://www.cfd-online.com/Forums/fluent-udf/63231-problem-dynamic-mesh-piston-model.html*)

problem of dynamic mesh for a piston modelHi,
I have to model a problem of a piston in a cylinder and i want to make an UDF in order to move the piston 2 mm before then 6 mm behind. have you any idea about the UDF to do this? and any advices for this kind of problem? Thanks |

you may use the macro DEFINE_CG_MOTION.
Please refer to chapter 2.6.1 from help ************* Example: /************************************************** ********** * 1-degree of freedom equation of motion (x-direction) * compiled UDF ************************************************** **********/ /#include "udf.h" static real v_prev = 0.0; DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime) { Thread *t; 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 */ 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; 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; } |

Can anyone explain to me the use of resetting the velocity? "NV_S (vel, =, 0.0);"
I am also trying to model a simple piston in a tube but am having problems with the motion/results |

All times are GMT -4. The time now is 08:37. |