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

- - **Problem with CG Motion**
(*https://www.cfd-online.com/Forums/fluent-udf/99870-problem-cg-motion.html*)

Problem with CG MotionI'm having a little trouble with the Define_CG_Motion macro. I'm trying to do a simulation of a cylinder moving as a result of pressure and shear forces. This is an image of the problem:
http://i39.tinypic.com/1zg4yo3.jpg I'm using this UDF, but a moment after I'm starting the calculation an "access violation" error appear.. #include "udf.h" #include "stdio.h" #include "stdlib.h" #include "math.h" #include "dynamesh_tools.h" #include "storage.h" static real v0_prev = 0.0; static real v1_prev = 0.0; static real v2_prev = 0.0; DEFINE_CG_MOTION(CoGRAVITY_M,dt,vel,omega,time,dti me) { Thread *t; face_t f; real NV_VEC(A); real force0, force1, force2; real dv0, dv1, dv2; real mass = 0.5; /* reset velocities */ NV_S(vel, =, 0.0); NV_S(omega, =, 0.0); if (!Data_Valid_P()) /* Do nothing if gradient isn’t allocated yet. */ return; /* get the thread pointer for which this motion is defined */ t = DT_THREAD(dt); /*reset forces*/ force0 = 0.0; force1 = 0.0; force2 = 0.0; begin_f_loop(f,t) { F_AREA(A,f,t); force0 += F_P(f,t)*A[0] + F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[0]; force1 += F_P(f,t)*A[1] + F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[1]; force2 += F_P(f,t)*A[2] + F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[2]; } end_f_loop(f,t) /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv0 = dtime * force0 / mass; dv1 = dtime * force1 / mass; dv2 = dtime * force2 / mass; v0_prev += dv0; v1_prev += dv1; v2_prev += dv2; /* sets the components of velocity */ vel[0] = v0_prev; vel[1] = v1_prev; vel[2] = v2_prev; printf ("force0 = %f, force1 = %f, X_force2 = %f\n", force0, force1, force2); } I've defined all dynamic mesh zones as "deforming" except for the solid interface zone "contact_region-trg" which is defined as "rigid body" with the above UDF. Any help in this regard will be very appreciated. with kind regards, Jessica. |

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