
[Sponsors] 
April 9, 2011, 04:05 
code in dynamic meshing udf

#1 
Senior Member
raymond
Join Date: Nov 2009
Posts: 149
Rep Power: 7 
I have gone through the UDF reference guide provided by FLUENT and the following is the dynamic mesh UDF in the reference guide.
/************************************************** ********** * 1degree of freedom equation of motion (xdirection) * 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 xcomponent of velocity */ vel[0] = v_prev; } I am facing difficulties in understanding the UDF written especially as redmarked as above. Can please anyone explain the meaning for me? Thanks for your help. Best regard 

April 10, 2011, 11:57 

#2 
New Member
Petrut Teodor
Join Date: Feb 2010
Location: Romania
Posts: 12
Rep Power: 7 
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. Last edited by teopetre; April 10, 2011 at 12:51. 

April 10, 2011, 21:06 

#3  
Senior Member
raymond
Join Date: Nov 2009
Posts: 149
Rep Power: 7 
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 

April 21, 2011, 14:33 
Very good question!

#4 
New Member
Petrut Teodor
Join Date: Feb 2010
Location: Romania
Posts: 12
Rep Power: 7 
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. 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF CG_MOTION rotation dynamic mesh  Mads  FLUENT  2  April 15, 2014 03:30 
negative cell volume during dynamic meshing  Tamjid  FLUENT  1  September 5, 2011 02:33 
Is there a free CFD code with dynamic mesh?  lzgwhy  Main CFD Forum  0  September 18, 2010 02:37 
Dynamic Meshing  James  FLUENT  0  May 31, 2004 07:27 
Design Integration with CFD?  John C. Chien  Main CFD Forum  19  May 17, 2001 15:56 