|
[Sponsors] |
August 22, 2018, 15:03 |
Moving mesh udf problem
|
#1 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Dear users.
I try to define flapping plate having center gravity moving. I use the simple udf DEFINE_CG_MOTION(foil0, dt, cg_vel, cg_omega, time, dtime) { cg_omega[2] = ThetAmp*ang_vel*cos(ang_vel*time); } The udf hooked to constant center of rotation. However, in my problem, the rotation center is moving as well. My question is: which way can I define move of rotation center. Thank you a lot in advance. |
|
August 23, 2018, 07:36 |
|
#3 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Dear blackmask.
Thank you for so quick and useful response. wXdr = wVdT in i direction and wUdT in j direction, so i changed the udf in following manner: cg_vel[0] = -0.7*w*sin(w*time)+w*cg_vel[1]*dtime; cg_vel[1] = 0.7*w*cos(w*time)+w*cg_vel[0]*dtime; just added linear component. and cg_omega[2] = w*0.7; when 0.7 is r-r0. the result was similar to snail shield. What wrong in my view of the problem? Thank you a lot in advance. |
|
August 23, 2018, 23:25 |
|
#4 |
Senior Member
|
In my post all of are vectors, so it does not make sense that a vector is a scalar, i.e., 0.7 as you mentioned. The vector denotes the center of gravity (rotation) you input in the attribute page, and denotes the actual center of rotation. Can you elaborate more on the motion of center of rotation in your problem? The code should looks like:
Code:
DEFINE_CG_MOTION(foil0, dt, cg_vel, cg_omega, time, dtime) { real dx, dy ; /* [dx, dy] = r0 - r1 */ dx = ...; /* dx, dy can be time-dependent */ dy = ...; /* note that dx, dy is in the fixed-frame rather than in the moving frame */ cg_omega[2] = ThetAmp*ang_vel*cos(ang_vel*time); cg_vel[0] = -cg_omega[2]*dy; cg_vel[1] = cg_omega[2]*dx; } |
|
August 24, 2018, 04:35 |
|
#5 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Dear blackmask.
First of all thank you so much for so informative help collaboration. The general trajectory of rotation center is elliptical. By the way the rotation center is not gravity center in this case. But it is no matter because both of them is known, and gravity center detection is not take place in the udf. Again, thank you a lot for the help. |
|
August 27, 2018, 02:54 |
|
#6 |
Senior Member
|
||
August 27, 2018, 03:31 |
|
#7 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Dear blackmask.
The body has elliptical trajectory in stationary domain, however, orientation of body is not strongly in direction of trajectory but tilted. That a reason why i've thought to move the body relative, say, point [0,0], thereafter rotate it relative new rotation (mass center) position. Unfortunately i can read the mass center of body each time step, but i don't know to define center rotation point via udf. |
|
August 27, 2018, 06:43 |
|
#8 |
Senior Member
|
I am so sorry that I did not test before I answered your question. The method I proposed before simply does not work. I managed to modify the CoG(CoR) by modifying three (init, tmp, current) state variables at the same time. The body does change the center of rotation, however an abrupt translation of the body is observed at the same time. Below is the code for your reference. The rigid body is a two-dimensional airfoil whose leading and trailing edge point is located at (0, 0) and (1, 0), respectively. It first rotate around (0, 0) at an angular velocity of for one second, and then its center of rotation is changed to . Note that when this UDF is executed, the CoG(CoR) in the GUI is changed accordingly.
Code:
DEFINE_CG_MOTION(from_ori_to_cg, dt, cg_vel, cg_omega, time, dtime) { const real pi = 4.0*atan(1.0); const real ang_vel = pi/6.0; const real ttt = 1.0; static int ccstep; int n_ts = time/dtime+0.5; ccstep = 1.0/dtime + 0.5; Message("ccstep = %d, N_TIME = %d\n", ccstep, n_ts); /* * rotation and translation in the absolute reference frame */ DT_NEST_LOC_ROT_P(dt) = FALSE; DT_NEST_LOC_TRAN_P(dt) = FALSE; /* in t = 0s, R0 = (0, 0, 0) */ /* in ttt = 1s, the CoG will be located at */ /* R1 = (L/2*cos theta, L/2*sin theta, 0), where theta=ang_vel*t */ real dy = sin(ang_vel*ttt)/2.0, dx = cos(ang_vel*ttt)/2.0; cg_omega[2] = ang_vel; if (n_ts == ccstep) { dt->current_state.cg[0] = dx; dt->current_state.cg[1] = dy; dt->init_state.cg[0] = dx; dt->init_state.cg[1] = dy; dt->tmp_state.cg[0] = dx; dt->tmp_state.cg[1] = dy; } Message("time: %g, CoRc = (%g, %g, %g), CoRi = (%g, %g, %g)\n", time, dt->current_state.cg[0], dt->current_state.cg[1], dt->current_state.cg[2], dt->init_state.cg[0], dt->init_state.cg[1], dt->init_state.cg[2], ); } |
|
August 27, 2018, 07:21 |
|
#9 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Wow,that exactly what i am looking for.
Thank you so much... Tell me pls, where do you take list of all functions, libraries,structures,sub-structures and variables for udf? I have not found it in fluent manual and tutorials? Thank you very much again.... |
|
August 27, 2018, 09:17 |
|
#10 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Dear blackmask
The code works perfect. However i still have a problem. Ones i use: cg_vel[0] = -ang_vel*sin(ang_vel*time); cg_vel[1] = ang_vel*cos(ang_vel*time); with manually defined rotation center,(in my case is [0,0] i get circular translation. Ones i use: cg_omega[2] = ang_vel; with manually defined rotation center,(in my case is [0.7,0] i get rotation on the place around it selves (because radius vector is 0). What means, ones i change rotation center, translation and rotation should be independent. However it does not happen. I get snail shield trajectory. The code is: #include "udf.h" #define freq 1 #define XAmp 0.7 #define YAmp 0.7 #define ang_vel 2*M_PI*freq DEFINE_CG_MOTION(test, dt, cg_vel, cg_omega, time, dtime) { /*center rotation of body-function of time*/ dt->current_state.cg[0] =XAmp*cos(ang_vel*time); dt->current_state.cg[1] =YAmp*sin(ang_vel*time); dt->init_state.cg[0] = XAmp*cos(ang_vel*time); dt->init_state.cg[1] = YAmp*sin(ang_vel*time); dt->tmp_state.cg[0] = XAmp*cos(ang_vel*time); dt->tmp_state.cg[1] = YAmp*sin(ang_vel*time); /*rotation*/ cg_omega[2] = ang_vel; /*i suppose the rotation does not have effect on body position, only on orientation*/ /*center translation definition-point [0,0]*/ dt->current_state.cg[0] = 0.0; dt->current_state.cg[1] = 0.0; dt->init_state.cg[0] = 0.0; dt->init_state.cg[1] = 0.0; dt->tmp_state.cg[0] = 0.0; dt->tmp_state.cg[1] = 0.0; /*translation-hase effect only on position of body but not on otientation*/ cg_vel[0] = -ang_vel*sin(ang_vel*time); cg_vel[1] = ang_vel*cos(ang_vel*time); } Something incorrect there. Thank you a lot in advance |
|
August 27, 2018, 11:42 |
|
#11 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
You can find that there is no presence of follow lines in the code:
/* * rotation and translation in the absolute reference frame */ DT_NEST_LOC_ROT_P(dt) = FALSE; DT_NEST_LOC_TRAN_P(dt) = FALSE; Because with the lines, code do not pass compilation with next error message: error C2106: '=' : left operand must be l-value may be this is a problem? Thanks |
|
August 27, 2018, 21:55 |
|
#12 |
Senior Member
|
||
August 28, 2018, 08:36 |
|
#13 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Dear blackmask.
I tried the version and got response: error C2039: 'nested_local_rot_p' : is not a member of 'dynamic_thread_struct' error C2039: 'nested_local_tran_p' : is not a member of 'dynamic_thread_struct' may be i should use additional header (library) and use : DT_NEST_LOC_ROT_P(dt) = FALSE; DT_NEST_LOC_TRAN_P(dt) = FALSE; ??? Thanks |
|
August 28, 2018, 09:17 |
|
#15 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
I use fluent 16.1
|
|
August 28, 2018, 09:22 |
|
#16 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Should i hook "dynamesh_tools.h" in some way?
Or it hooked automatically once i use #include "udf.h" |
|
August 28, 2018, 09:32 |
|
#17 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Tried to add
#include "dynamesh_tools.h" The problem is still.... |
|
August 28, 2018, 09:55 |
|
#18 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
Ok, I have changed fluent version, so with
DT_NEST_LOC_ROT_P(dt) = FALSE; DT_NEST_LOC_TRAN_P(dt) = FALSE; compiling was passed, but it still snail shield trajectory.... |
|
August 28, 2018, 09:59 |
|
#19 |
New Member
Join Date: Mar 2009
Posts: 14
Rep Power: 17 |
even with
DT_NEST_LOC_ROT_P(dt) = TRUE; DT_NEST_LOC_TRAN_P(dt) = TRUE; it doesn't works |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 06:38 |
Dynamic mesh Problem: How can I set UDF to the motion of train? | Majid Zarif | Fluent UDF and Scheme Programming | 4 | January 27, 2015 03:44 |
Trying to set up Moving Mesh Problem | dreamchaser | CFX | 5 | December 15, 2014 01:07 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
a problem about DEFINE_GEOM in dynamic mesh UDF | speedcat | FLUENT | 1 | May 16, 2005 04:09 |