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

Flap motion UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 17, 2020, 06:50
Default Flap motion UDF
  #1
New Member
 
Egnir
Join Date: Oct 2019
Posts: 7
Rep Power: 6
EGNIR is on a distinguished road
I am trying to make flap motion for wavemaker. I have Z axis as my flap and X axis for forward motion. I tried to make a code for flap motion although the when tried mesh preview, the whole flap zone is moving forward. I want the bottom coordinate to be stationary and upper coordinate to move from - X to X axis.

#include "udf.h"
#include "dynamesh_tools.h"

static real period = 1.0;
static real amplitude = 0.1;
static real pi = 3.14159265358979323846;
static real depth = 0.5;
static real s = 0.1; /* define the stroke */


DEFINE_CG_MOTION(oscillate,dt,vel,omega,time,dtime )
{
/* define the variables */
Thread *t;
face_t f;
real dv, ang_freq;
real x[ND_ND];
real z;
/* get the thread pointer for which this motion is defined */
t = DT_THREAD(dt);
ang_freq = 2 * pi / period;


/* loop over each face in the zone to create an array of data */
begin_f_loop(f,t)
{
/* set x-component of velocity */
F_CENTROID(x,f,t);
z = x[2];
vel[0] = ((z+depth)/depth)* s * cos(ang_freq * time)/4 ;
}
end_f_loop(f,t)

Message("time = %f, x_vel = %f\n", time, vel[0]);
}
EGNIR is offline   Reply With Quote

Old   February 17, 2020, 07:23
Default Define_cg_motion
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
The macro used, as its name implies, is meant for moving CG of a complete zone. For flapping, I suppose you wish to move different nodes by different displacement values. Therefore, you should use DEFINE_GRID_MOTION. If the flap is rigid, then you may not require deforming mesh; moving mesh might do the job.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 18, 2020, 09:11
Default coordinate
  #3
New Member
 
Egnir
Join Date: Oct 2019
Posts: 7
Rep Power: 6
EGNIR is on a distinguished road
Quote:
Originally Posted by vinerm View Post
The macro used, as its name implies, is meant for moving CG of a complete zone. For flapping, I suppose you wish to move different nodes by different displacement values. Therefore, you should use DEFINE_GRID_MOTION. If the flap is rigid, then you may not require deforming mesh; moving mesh might do the job.
I tried making it with nodes although i used CG motion ,

here is the code,

#include "udf.h"
#include "dynamesh_tools.h"
DEFINE_CG_MOTION(oscillate,dt,vel,omega,time,dtime )
{
Thread *tf = DT_THREAD (dt);
face_t f;
Node *z2;
real NV_VEC (velocity), NV_VEC (axis);
real NV_VEC (origin), NV_VEC (rvec);
real velc;
real freq;
real amp;
real w;
int n;
real s;
real depth;
real z1;
/* set deforming flag on adjacent cell zone */

SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf));
freq=1;
w=2*3.141592654*freq;
s= 0.2 ;
depth =0.5;
z1= 1;
velc = ((z1+depth)/depth)*s* cos(w* time)/4;
NV_S (velocity, =, 0.0);
NV_D (axis, =, 0.0,1,1);
NV_D (origin, =, 0.0, 0.0, 0.0);/*center of gravity for my flap*/

begin_f_loop (f, tf)

{
f_node_loop (f, tf, n)

{
z2 = F_NODE (f, tf, n);

if (NODE_Z (z2) < 1.1 && NODE_POS_NEED_UPDATE (z2))
{
velocity[0] = NODE_Z (z2)*velc;

NV_V_VS (rvec, =, NODE_COORD (z2), +, velocity, *, dtime);
NV_V (NODE_COORD (z2), =, rvec);
}
}
}
end_f_loop (f, tf);
Message("time = %f, x_vel = %f\n", time, velocity[0]);
}

although it is moving like a flap the nodes on the edge are fixed and the rest are moving, I want the whole zone to move. I have attached a flap motion picture for reference.
Attached Images
File Type: png flapmotion.PNG (8.5 KB, 21 views)
EGNIR is offline   Reply With Quote

Old   February 18, 2020, 14:36
Default CG_MOTION vs GRID_MOTION
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
I am not sure if I completely understand your requirement but I hope the following is helpful

1. CG_MOTION is used for the rigid body motion where the motion is specified by the user and the nodes or cells of the rigid zone maintain their relative position. Fluent allows this macro to be used if rigid body is selected under the Type in Dynamic Mesh Zone definition. A flap may be governed by this if all its boundaries maintain their shape and size.

2. GRID_MOTION is used for the zone that may have relative motion between its nodes or cells. A flap that deflects like a cantilever beam with deflection being a nonlinear function of distance from fixed edge is governed by this macro. If this is the requirement, you should NOT use CG_MOTION and switch to GRID_MOTION.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 25, 2020, 04:49
Default
  #5
New Member
 
Egnir
Join Date: Oct 2019
Posts: 7
Rep Power: 6
EGNIR is on a distinguished road
thanks my requirement was first. I have a rigid body for flap. Now I have made the flap movement possible also my wave elevation are not regular. They are getting damped with time. 2m waveprobe.PNG

here is the code for flap motion.

#include "udf.h"
#include "dynamesh_tools.h"

real pi, freq, phase, w, AVel, A1, s,depth,z1,y,x[ND_ND],velc,A2;

DEFINE_CG_MOTION(wallmotion, dt, vel, omega, time, dtime)
{
Thread *t;
face_t f;
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

/* Defined Constants*/
pi = 3.141592654;
freq =1.458;
s= 0.2 ;
depth =0.5;

/*Define Wall Motion via. Angular Velocity */
t = DT_THREAD(dt);
w=2.0*pi*freq; /*angular freq in radians*/
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[2];
velc = ((y+depth)/depth)*s*w*cos(w* time)/4;
AVel = velc;
omega[1] = -AVel; /*Assign AVel to omegaz */
}
end_f_loop(f,t)
Message("time = %f, x_vel = %f\n", time, omega[1]);
}
EGNIR is offline   Reply With Quote

Old   February 25, 2020, 05:57
Default Code
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Few important points

1. x[2] implies z-coordinate. You can call it y but within a case, it will address z-coordinate

2. omega[1] is velocity about y-axis.

3. Rigid body implies no relative motion across space. But by using omega[1] inside the face loop implies each face has its own omega. That will distort the geometry leading to a conflict of the body being flexible.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 25, 2020, 06:42
Default
  #7
New Member
 
Egnir
Join Date: Oct 2019
Posts: 7
Rep Power: 6
EGNIR is on a distinguished road
yes I wanted z coordinate as that is my flap length. In my case the Z coordinate shows the height of the wave tank, X shows the lenght and y shows the width. That's why I choose omega [1] so that my flap moves accordingly.

According to your 3 point, can it be the reason for my irregular wave??

I tried omega[1] outside the face loop, it gives negative error volume. I tried the time step according to the 1/2 of the lenght scale. So is it because my omega[1] was not inside the face loop??
EGNIR is offline   Reply With Quote

Old   February 25, 2020, 07:04
Default Negative volume
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
With omega inside face loop, every node on the boundary will be rotated by a different value of omega. This may cause drastic mesh deformation very close to the flap and negative volume may result. Do note that negative volume may result due to any motion if either the mesh is not of good quality initially or the setup for deformation is wrong.
EGNIR likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with UDF for CG Circular Motion luthlau Fluent UDF and Scheme Programming 1 September 16, 2016 02:08
How to use "translation" in solidBodyMotionFunction in OpenFOAM rupesh_w OpenFOAM Running, Solving & CFD 5 August 16, 2016 04:27
UDF Problem about Grid Motion !!! Zhengyu Gao Fluent UDF and Scheme Programming 0 December 6, 2013 19:45
incorrect grid motion UDF deforming on zone ?????? h.iraji FLUENT 0 October 29, 2013 02:43
Is this the correct approach to my problem? (UDF for object in motion) charlestan88 Fluent UDF and Scheme Programming 5 October 27, 2013 06:09


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