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

Moving mesh udf problem

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 22, 2018, 15:03
Cool Moving mesh udf problem
  #1
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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.
vitali31 is offline   Reply With Quote

Old   August 23, 2018, 04:50
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
You do not have to change the rotation center. Note that

\omega \times (r - r_1) = \omega \times (r - r_0) + \omega \times (r_0 - r_1)

which means you can effectively change the rotation center from r_0 to r_1 by superimpose a linear velocity \omega \times (r_0 - r_1).
vitali31 likes this.
blackmask is offline   Reply With Quote

Old   August 23, 2018, 07:36
Default
  #3
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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.
vitali31 is offline   Reply With Quote

Old   August 23, 2018, 23:25
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
In my post all of r, r_0, r_1 are vectors, so it does not make sense that a vector is a scalar, i.e., 0.7 as you mentioned. The vector r_0 denotes the center of gravity (rotation) you input in the attribute page, and r_1 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;
}
blackmask is offline   Reply With Quote

Old   August 24, 2018, 04:35
Default
  #5
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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.
vitali31 is offline   Reply With Quote

Old   August 27, 2018, 02:54
Default
  #6
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Quote:
Originally Posted by vitali31 View Post
The general trajectory of rotation center is elliptical.
Is the elliptical trajectory in the stationary frame or rigid-body frame? The former is straightforward while the latter needs more work because you have to keep track of the orientation of the rigid body.
blackmask is offline   Reply With Quote

Old   August 27, 2018, 03:31
Default
  #7
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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.
vitali31 is offline   Reply With Quote

Old   August 27, 2018, 06:43
Default
  #8
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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 \pi/6 for one second, and then its center of rotation is changed to (\sqrt{3}/2, 1/2). 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],
            );
}
blackmask is offline   Reply With Quote

Old   August 27, 2018, 07:21
Default
  #9
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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....
vitali31 is offline   Reply With Quote

Old   August 27, 2018, 09:17
Default
  #10
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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
vitali31 is offline   Reply With Quote

Old   August 27, 2018, 11:42
Default
  #11
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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
vitali31 is offline   Reply With Quote

Old   August 27, 2018, 21:55
Default
  #12
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
The following two lines
Quote:
Originally Posted by vitali31 View Post
DT_NEST_LOC_ROT_P(dt) = FALSE;
DT_NEST_LOC_TRAN_P(dt) = FALSE;
can be replaced by
Code:
dt->nested_local_rot_p = FALSE;
dt->nested_local_tran_p = FALSE;
However, the latter is exactly the former with macro expansion.
blackmask is offline   Reply With Quote

Old   August 28, 2018, 08:36
Default
  #13
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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
vitali31 is offline   Reply With Quote

Old   August 28, 2018, 09:15
Default
  #14
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Which version do you use? In v18 the
Code:
struct dynamic_thread_struct
is defined in header "dynamesh_tools.h".
blackmask is offline   Reply With Quote

Old   August 28, 2018, 09:17
Default
  #15
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
I use fluent 16.1
vitali31 is offline   Reply With Quote

Old   August 28, 2018, 09:22
Default
  #16
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
Should i hook "dynamesh_tools.h" in some way?
Or it hooked automatically once i use #include "udf.h"
vitali31 is offline   Reply With Quote

Old   August 28, 2018, 09:32
Default
  #17
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
Tried to add
#include "dynamesh_tools.h"
The problem is still....
vitali31 is offline   Reply With Quote

Old   August 28, 2018, 09:55
Default
  #18
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
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....
vitali31 is offline   Reply With Quote

Old   August 28, 2018, 09:59
Default
  #19
New Member
 
Join Date: Mar 2009
Posts: 14
Rep Power: 17
vitali31 is on a distinguished road
even with
DT_NEST_LOC_ROT_P(dt) = TRUE;
DT_NEST_LOC_TRAN_P(dt) = TRUE;

it doesn't works
vitali31 is offline   Reply With Quote

Old   August 28, 2018, 22:16
Default
  #20
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
They change the data structure across various versions. You can take a look at the header files and find if there is anything you can do about it.
blackmask is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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


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


All times are GMT -4. The time now is 11:46.