- **FLUENT**
(*http://www.cfd-online.com/Forums/fluent/*)

- - **code in dynamic meshing udf**
(*http://www.cfd-online.com/Forums/fluent/87021-code-dynamic-meshing-udf.html*)

code in dynamic meshing udfI have gone through the UDF reference guide provided by FLUENT and the following is the dynamic mesh UDF in the reference guide.
/************************************************** ********** * 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; } I am facing difficulties in understanding the UDF written especially as red-marked as above. Can please anyone explain the meaning for me? Thanks for your help. Best regard :) |

The utility NV_V or NV_S performs an operation on two vectors.
NV comes from Normal Vector, NV_MAG(A) returns the magnitude of area faces. NV_S initializes the velocity vector and angular velocity vector with the scalar 0 value, S is from scalar. Variable v_prev is a static variable. NV_V(a, =, x); a[0] = x[0]; a[1] = x[1]; etc. Note that if you use + = instead of = in the above equation, then you get a[0]+=x[0]; etc. See the fluent manual at http://jullio.pe.kr/fluent6.1/help/pdf/udf/fl61udf.pdf chapter 6 section 6. |

Quote:
Thanks a lot, Teopetre. What is 0.0? Is it value of zero? What is the difference between 0 and 0.0? Best regard |

Very good question!I've never noticed this fact, I'm not quite sure about the answer I'm gonna give it to you: those capital letter functions you have in your program are in fact calling functions from the Fluent's code programming Scheme, a LISP dialect, and this programming language doesn't make any difference between integer, real or floating point numbers. So, '0.0' and '0' are the same working variable type in Scheme. You may try putting just '0' to see what's happening, both in 2d and 2ddp.
Sorry for the late intervention. |

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