CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Define_CG_Motion

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 6, 2016, 07:10
Angry Define_CG_Motion
  #1
New Member
 
' w '
Join Date: Apr 2015
Posts: 6
Rep Power: 11
wanis is on a distinguished road
hi all,
really i would be appreciate if u help me because i am not familiar with c++ and coding to change this udf to 3 degree of freedom in x,y and z.


/************************************************** **********
* 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, that is, 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;
}

Thanks in advance
wanis is offline   Reply With Quote

Old   April 15, 2016, 06:45
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
This user-defined function (UDF) uses vector macros (including NV_VEC and NV_S) which should generally scale well for 3-D. Could you explain your problem in detail, including what this UDF currently does and what you're hoping to achieve by modifying it?
`e` is offline   Reply With Quote

Old   April 15, 2016, 12:43
Thumbs up
  #3
New Member
 
' w '
Join Date: Apr 2015
Posts: 6
Rep Power: 11
wanis is on a distinguished road
Quote:
Originally Posted by `e` View Post
This user-defined function (UDF) uses vector macros (including NV_VEC and NV_S) which should generally scale well for 3-D. Could you explain your problem in detail, including what this UDF currently does and what you're hoping to achieve by modifying it?
Thank you `e`, I am doing simulation of 3D moving of an object, i have tried to compile this UDF and then the motion of the object was restricted in one dimension which is stated in definition of UDF in X-direction, therefore i would like to see the movement also in other direction Y and Z. is there any way to modify it? really i don't know how and i am still studying about it and no progress achieved.
wanis is offline   Reply With Quote

Old   April 16, 2016, 21:50
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The UDF is currently modifying the velocity in the x-direction with this code segment:

Code:
/* set x-component of velocity */
vel[0] = v_prev;
You could change the direction which this velocity is applied to, for example in the y-direction:

Code:
/* set y-component of velocity */
vel[1] = v_prev;
Furthermore, if you wanted to apply the same speed in all three directions then:

Code:
/* set x-, y- and z-components of velocity (all equal in magnitude) */
vel[0] = v_prev;
vel[1] = v_prev;
vel[2] = v_prev;
If you'd like a different speed in each direction then modify the components accordingly. It appears the code calculates the pressure force on the body to find the resulting change in velocity. A piston is restricted to one direction which was why I asked you to describe your problem in further detail.
`e` is offline   Reply With Quote

Old   April 17, 2016, 13:15
Default
  #5
New Member
 
' w '
Join Date: Apr 2015
Posts: 6
Rep Power: 11
wanis is on a distinguished road
Really thank you `e` and I appreciate it, now it's more clear to me and i will see how to use another equations to define y, z components.
wanis is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 19:51.