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

2d Dynamic Mesh with udf

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

Like Tree9Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2010, 12:35
Default hi friend
  #21
New Member
 
euzinho
Join Date: May 2010
Posts: 15
Rep Power: 15
euzinho is on a distinguished road
this is exactly what I want to resolve
a udf or any other way to get this movement in a transient study




Quote:
Originally Posted by O.D.Y. View Post
Hey euzinho,

how large should the displacement of your body you showed in the picture get? If its only a small one, the smoothing should be sufficient.
But then you need to specify smoothing for all cell types via TUI as decribed above...

Did you properly assign the rigid body movements to your body in the dynamic mesh option? Can you post your udf?

cheers
Attached Images
File Type: jpg butterfly valve move.JPG (40.5 KB, 439 views)
Sittisak likes this.
euzinho is offline   Reply With Quote

Old   May 31, 2010, 03:55
Default
  #22
Member
 
O.D.Y.'s Avatar
 
Join Date: Mar 2009
Posts: 49
Rep Power: 17
O.D.Y. is on a distinguished road
Well sliding mesh could be an option...
The idea would be to split the flow domain into two parts.

Lets say one circle domain containing the valve and one for the rest of the domain, and the boundary between them could be defined as sliding mesh.

But as far as I know you can only specify constant movement, or you have to use an udf...

But the thing you want to do is quite easy to do with UDF...

Here is a simple version of what I am using:

#include <stdio.h>
#include <math.h>
#include "udf.h"

DEFINE_CG_MOTION(move_body, dt, vel, omega, time, dtime)
{
real ampl,disp,omg,count;

/* reset velocities */
NV_S (vel, =, 0.0);
NV_S (omega, =, 0.0);

/* motion */
ampl = 0.008726646 ; /* amplitude of rotation in radians (0.5deg) */
omg = 116.0219; /* angular frequency (18.465Hz) */
disp = ampl * sin(omg * time); /* resultant displacement */

omega[2] = ampl * omg * cos(omg * time);
}

So this is for a sinusoidal vibration with 0.5deg amplitude around the z-axis.
for your case you could take another functional dependency on time or let it only work in a certain time period using an if condition.

Then you need to hook this udf as rigid body motion and as center of gravity you just set the coordinates of the geometrical center point of your valve.

let me know if it works.

cheers
Sittisak likes this.
O.D.Y. is offline   Reply With Quote

Old   May 31, 2010, 05:23
Default
  #23
New Member
 
euzinho
Join Date: May 2010
Posts: 15
Rep Power: 15
euzinho is on a distinguished road
wow! friend, thanks so much for taking your time and help me out.
finally it works! this is the certain code for sure,
and actually this is what I did earlier but omega[2] coordenate didnīt work that time... I wonder why...

it leads me to another problem, however... so two more question, please
How can I define my CG "set the coordinates of the geometrical center point of your valve."
and how can I resolve negative cell volume problems..? is that because a wrong definition of my mesh?

thans again,




Quote:
Originally Posted by O.D.Y. View Post
Well sliding mesh could be an option...
The idea would be to split the flow domain into two parts.

Lets say one circle domain containing the valve and one for the rest of the domain, and the boundary between them could be defined as sliding mesh.

But as far as I know you can only specify constant movement, or you have to use an udf...

But the thing you want to do is quite easy to do with UDF...

Here is a simple version of what I am using:

#include <stdio.h>
#include <math.h>
#include "udf.h"

DEFINE_CG_MOTION(move_body, dt, vel, omega, time, dtime)
{
real ampl,disp,omg,count;

/* reset velocities */
NV_S (vel, =, 0.0);
NV_S (omega, =, 0.0);

/* motion */
ampl = 0.008726646 ; /* amplitude of rotation in radians (0.5deg) */
omg = 116.0219; /* angular frequency (18.465Hz) */
disp = ampl * sin(omg * time); /* resultant displacement */

omega[2] = ampl * omg * cos(omg * time);
}

So this is for a sinusoidal vibration with 0.5deg amplitude around the z-axis.
for your case you could take another functional dependency on time or let it only work in a certain time period using an if condition.

Then you need to hook this udf as rigid body motion and as center of gravity you just set the coordinates of the geometrical center point of your valve.

let me know if it works.

cheers
Sittisak likes this.
euzinho is offline   Reply With Quote

Old   June 1, 2010, 03:38
Default
  #24
Member
 
O.D.Y.'s Avatar
 
Join Date: Mar 2009
Posts: 49
Rep Power: 17
O.D.Y. is on a distinguished road
Hi,

well you just set the center of gravity in the dynamic mesh module to the coordinates of the geometric center of the body thats supposed to rotate.

the negative volumes may have different reasons.

As you are using quad-elements you have to set

/define/models/dynamic-mesh-controls/smoothing-parameter/spring-on-all-shapes? yes

via TUI otherwise the smoothing only works for tri- and tet-elements.

If you still have negative volumes you should think about making smaller displacement per time step (e.g. taking a smaller time step size).
You can also vary the parameters for smoothing and use the remeshing technique additionally.

good luck
O.D.Y. is offline   Reply With Quote

Old   June 1, 2010, 07:29
Default
  #25
New Member
 
euzinho
Join Date: May 2010
Posts: 15
Rep Power: 15
euzinho is on a distinguished road
thanks so much for your response,
actually I am setting my CG when I design the project in Solidworks, and it works

other question, where can I reset the "current mesh time" in order to start from the beginning?
I mean, after the body moves, How can I put it back at its initial position? what I do is to shut fluent down and start it over.. and itīs suck!


thanks


Quote:
Originally Posted by O.D.Y. View Post
Hi,

well you just set the center of gravity in the dynamic mesh module to the coordinates of the geometric center of the body thats supposed to rotate.

the negative volumes may have different reasons.

As you are using quad-elements you have to set

/define/models/dynamic-mesh-controls/smoothing-parameter/spring-on-all-shapes? yes

via TUI otherwise the smoothing only works for tri- and tet-elements.

If you still have negative volumes you should think about making smaller displacement per time step (e.g. taking a smaller time step size).
You can also vary the parameters for smoothing and use the remeshing technique additionally.

good luck
Attached Images
File Type: jpg question.jpg (100.1 KB, 280 views)
Durga Sravan likes this.
euzinho is offline   Reply With Quote

Old   June 1, 2010, 07:35
Default
  #26
Member
 
O.D.Y.'s Avatar
 
Join Date: Mar 2009
Posts: 49
Rep Power: 17
O.D.Y. is on a distinguished road
good question, you could reset the current mesh time in the mesh motion module in former versions, but I guess in 6.3.26 and newer versions this isn't possible anymore... This time is saved in the *.dat file.

You could just substract this time from the time variable in the udf and compile again... I don't know about another way..
O.D.Y. is offline   Reply With Quote

Old   June 1, 2010, 09:07
Default
  #27
New Member
 
euzinho
Join Date: May 2010
Posts: 15
Rep Power: 15
euzinho is on a distinguished road
I did it!
it is a simple armonic movement
what I cannot get is to set certain movement in a given period of time.
I mean, I have to open the valve in 2 seconds. thatīs all

after that, the aim is to maintain the valve opened
but If I cannot have a control of "time" I cannot control that..

I was thinking about something like:

if (time=2) (guessing that Time in seconds) then omega[2] = 0 (because the valve will stop once reached that time)

any suggestion?

thanks

Last edited by euzinho; June 1, 2010 at 09:57.
euzinho is offline   Reply With Quote

Old   June 2, 2010, 04:07
Default
  #28
Member
 
O.D.Y.'s Avatar
 
Join Date: Mar 2009
Posts: 49
Rep Power: 17
O.D.Y. is on a distinguished road
Why not, that should work....
O.D.Y. is offline   Reply With Quote

Old   June 2, 2010, 04:19
Default
  #29
New Member
 
euzinho
Join Date: May 2010
Posts: 15
Rep Power: 15
euzinho is on a distinguished road
well, it doesnīt work because "time" is greater than 2 and there is no way to resert its value...

Quote:
Originally Posted by O.D.Y. View Post
Why not, that should work....
euzinho is offline   Reply With Quote

Old   June 3, 2010, 08:56
Default
  #30
New Member
 
Christophe
Join Date: Apr 2010
Posts: 2
Rep Power: 0
cheaklapomme is on a distinguished road
Hi guys,

I'v read all your posts, I tried everything you've said, but (yes there is always a 'but') I always have the best answer in the world

'Update dynamic mesh failed. Negative cell volume detected'

My project is blood simulation in artery, and what I want to do now is a simulation of the movement of the artery.

First of all I'll try to do that with an easy one, that's mean with a pipe.
Here is my UDF :

# include "udf.h"
# include "dynamesh_tools.h"
# define D 0.2e-2 /* diameter of the pipe */
# define H 0.03e-2 /* amplitude of the wave */
# define L 1e-2 /* length of the wave */
# define l 2e-2 /* lenght of the pipe */
# define speed_wave 1 /* speed of the wave */
static real F(real x)
{
if (x>=0 && x<L)
{ return H*sin(2*M_PI/L*(x-0.25*L))+0.5*D+H; }
else if(x>=L && x<=(L+l))
{ return 0.5*D; }
else
{ Message0("x = %12.4e Wrong range of x-aborting", x);
exit(1); }
}

static real f_top(real x)
{
real x1;
double tmp;
x1 = modf(x/(L+l), &tmp);
if (x1>=0)
{
return F(x1*(L+l)); }
else
{
return F((1+x1)*(L+l)); }
}
static real f_bottom(real x)
{
return -f_top(x);
}

DEFINE_GRID_MOTION(grid_top, domain, dt, time, dtime)
{
face_t f;
Thread *tf = DT_THREAD ((Dynamic_Thread *)dt);
int n;
Node *v;
/* Activate the deforming flag on adjacent cell zone, which means that
the cell adjacent to the deforming wall will also be deformed in
order to avoid skewness. */
SET_DEFORMING_THREAD_FLAG (THREAD_T0(tf));

/* Loop over the deforming boundary zone's faces; inner loop loops over
all nodes of a given face; */
begin_f_loop(f, tf)
f_node_loop(f, tf, n)
{
v = F_NODE(f, tf, n);
{
/* Update the current node only if it has not been previously visited to
avoid to visit the same nodes multiple times */

if (NODE_POS_NEED_UPDATE(v))

{
/* Set flag to indicate that the current node's position has been
updated, so that it will not be updated during a future
pass through the loop */
NODE_POS_UPDATED(v);
real x;
x = NODE_X(v);
/* f_top(x-ct) defines the wave equation */
NODE_Y(v) = f_top(x-speed_wave*time);
}
}
Update_Face_Metrics (f, tf);
}
end_f_loop (f, tf);
}

/* Similar udf for the bottom wall */
DEFINE_GRID_MOTION(grid_bot, domain, dt,
time, dtime)
{
face_t f;
Thread *tf = DT_THREAD ((Dynamic_Thread
*)dt);
int n;
Node *v;
SET_DEFORMING_THREAD_FLAG
(THREAD_T0(tf));
begin_f_loop(f, tf)
{
f_node_loop(f, tf, n)
{

v = F_NODE(f, tf, n);
if (NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
real x;
x = NODE_X(v);
NODE_Y(v) = f_bottom(x-speed_wave*time);
}
}
Update_Face_Metrics (f, tf);
}
end_f_loop (f, tf);

}

I'm waiting for your possibilities and advices.

Thanks a lot in advance.

Christophe
cheaklapomme is offline   Reply With Quote

Old   August 3, 2010, 02:22
Default rotation about z axis
  #31
Member
 
ahmad
Join Date: Jul 2010
Posts: 57
Rep Power: 15
almostafa67 is on a distinguished road
hi everybody...
first please let me brief you my problem,these two image that i sent you were simulated in gambit, both of them are kind of peristaltic pump,i want to rotate two/one small cylinder about z axis,i should write an udf,for this simple movement i used following udf
# include "udf.h"
# include "dynamesh_tools.h"
DEFINE_CG_MOTION(pump,dt,vel,omega,time,dtime)
{
Thread *t;

real freq_t;
NV_S(vel,=,0.0);
NV_S(omega,=,0.0);
if(!Data_Valid_P())
return;
freq_t = 4.0;
t= DT_THREAD((Dynamic_Thread*)dt);
vel[0] = 0.0;
vel[1] = 0.0;
vel [2] = 0.0;
omega [0] = 0.0;
omega [1] = 0.0;
omega [2] = freq_t;
}
but it does not work
i will be thankful if you could help me out
looking forward to ur help.
Attached Images
File Type: jpg 1.JPG (68.2 KB, 177 views)
File Type: jpg 2.JPG (79.1 KB, 118 views)
almostafa67 is offline   Reply With Quote

Old   August 5, 2010, 09:48
Default update-dynamic-mesh failed. negative cell volume detected.
  #32
Member
 
ahmad
Join Date: Jul 2010
Posts: 57
Rep Power: 15
almostafa67 is on a distinguished road
hi dear all...
I was running fluent and waiting to get results but faced an error:

update-dynamic-mesh failed. negative cell volume detected.

i changed time step from 0.0001 to 0.00001 but again this error showed up,could you help me out plz?
thank u in advanced for any help provided
almostafa67 is offline   Reply With Quote

Old   August 8, 2010, 08:13
Default How to activate"spring-all-shapes"?
  #33
Member
 
ahmad
Join Date: Jul 2010
Posts: 57
Rep Power: 15
almostafa67 is on a distinguished road
hi dear all...
i faced an error message,negative cell volume detected,i think if i activate spring-on-all shapes this error does show again,but i do not know hoe to activate it in ansys 12.0,
any help will be appreciated...
almostafa67 is offline   Reply With Quote

Old   September 22, 2010, 10:06
Default butterfly valve
  #34
Member
 
andres
Join Date: Sep 2010
Posts: 44
Rep Power: 15
cfdhydraulic is on a distinguished road
I O.D.Y how it is going?
I am in trouble one more time with butterfly valve move... I hope you can manage to help me out.
Time ago you gave me the following code to resolve butterfly move and I have been changing some parameter to adapt your code to my requirements without success
what I have to do is to stop this valve after 45š displacement. thatīs all.

If you have any idea to do it, I would appreciate if you share this thoughs.
regards


DEFINE_CG_MOTION(rotating_body, dt, vel, omega, time, dtime)
{
real ampl,disp,omg,count;

NV_S (vel, =, 0.0);
NV_S (omega, =, 0.0);

/* motion */
ampl = 0.785423 ;
omg = 516.0219;
disp = ampl * sin(omg * time);

omega[2] = 0.785423*sin(time);
cfdhydraulic is offline   Reply With Quote

Old   June 28, 2011, 09:32
Default
  #35
Member
 
Alberto Pellegrino
Join Date: Jan 2011
Posts: 32
Rep Power: 15
AlbertoP is on a distinguished road
Hi O.D.Y.,

you mentioned that negative volume problems can be solved tuning the smoothing or re-meshing parameters.

But I have this problem even if I work with sliding mesh (circle inner quad-mesh oscillating, and outer tri-mesh steady), so without smoothing or re-meshing.

Any idea about why I get negative volumes (when I run a preview mesh motion on Fluent) and how to solve it, please?

Many thanks.
Kind regards,

Alberto
AlbertoP is offline   Reply With Quote

Old   June 27, 2012, 03:11
Default
  #36
Member
 
Satish Gupta
Join Date: Jun 2012
Posts: 30
Rep Power: 13
Rahul123 is on a distinguished road
I am using dynamic mesh to simulate a 2d square cylinder.My problem is only the cells adjacent to boundary deforms.Can any1 tell me what I should do to deform more portion of the mesh?
Rahul123 is offline   Reply With Quote

Old   December 16, 2012, 09:30
Default
  #37
Member
 
Vidit Sharma
Join Date: Aug 2012
Location: Delhi, India
Posts: 32
Rep Power: 13
Vidit Sharma is on a distinguished road
Hi All..

Sir,
I am trying to rotate a 2D box or a 2D cup structure in Fluent using smoothing and remeshing. I am using tri mesh and as mentioned in Fluent Manual I am using smoothing and remeshing and also set the remeshing parameters from mesh info tab given in the remeshing menu. But the problem is that when i start simulation and it goes to first time step Fluent display "Updating mesh at time level N..." and here it stops and it happened alot of time and even waiting after a whole day it didnt worked. I also tried time step size from 0.01 to 0.000001 but it still show this problem.

Can you plz help in this case?

Thank u in advance
Vidit Sharma is offline   Reply With Quote

Old   February 28, 2013, 23:57
Default 2D airfoil O Grid- negative volume
  #38
Member
 
samrat himvanth nanduri
Join Date: May 2012
Posts: 30
Rep Power: 13
samcfd is on a distinguished road
Hi,

I'm carrying out a 2D pitching airfoil simulation using dynamic meshing with a "O" Grid. The dynamic conditions i have given were
1) airfoil - rigid body with UDF with pitching over X=0.25
2)interior - deforming with the min and max length scale from zone scale info
3) fluid -deforming with the min and max length scale from zone scale info.

The spring constant i gave was 0.001 and
convergence tolerance 0.0001
No of iterations 150.

The time step tat i used is 0.001.

After running the iterations and after about 500 time steps i'm getting the following error

negative volume detected
dynamic mesh update failed.
i have worked around with the spring constant and also with the time step nothing worked.
could someone help me out rectify this issue..
thanks in advance,
sam
samcfd is offline   Reply With Quote

Old   February 17, 2016, 07:49
Default
  #39
New Member
 
Pradip
Join Date: Jan 2016
Location: Mumbai
Posts: 13
Rep Power: 10
pradip.c1000 is on a distinguished road
Sam cfd
can you tell me what options of fluent you choose for doing airfoil pitching analysis, I am doing bird wing flapping analysis. My email id is pradip.c1000@gmail.com
Thanks in advance.
pradip.c1000 is offline   Reply With Quote

Old   May 14, 2016, 03:03
Default
  #40
Senior Member
 
Arun raj.S
Join Date: Jul 2011
Posts: 194
Rep Power: 14
arunraj is on a distinguished road
Hi everyone,

I am simulating flapping wing of aerofoil. I have created three zones, zone 1, 2 and 3. Zone 1 has aerofoil with structured mesh around the aerofoil. Zone 2 and 3 has unstructured gird. My problem is I have properly followed all the steps. But I am not able to achieve what I want. Because the shadow of the interface is taking as wall and is not moving along with the domain. Kindly someone help in sorting out this issue. I have attached my UDF alos. Please have a look. Thank you so much

https://drive.google.com/file/d/0B7L...ew?usp=sharing
https://drive.google.com/file/d/0B7L...ew?usp=sharing
Attached Files
File Type: c second.c (1.1 KB, 47 views)
Sittisak likes this.
arunraj 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
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Dynamic mesh UDF problem Peter FLUENT 2 November 12, 2007 02:10
writing a dynamic mesh udf ALPER ALBAYRAQ FLUENT 0 October 24, 2005 08:41
Problem related with UDF for dynamic mesh Ryan FLUENT 6 April 29, 2004 09:29
UDF problem for dynamic mesh??? lyf FLUENT 1 April 19, 2004 06:43


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