CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   2d Dynamic Mesh with udf (https://www.cfd-online.com/Forums/fluent-udf/69840-2d-dynamic-mesh-udf.html)

euzinho May 30, 2010 12:35

hi friend
 
1 Attachment(s)
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. (Post 260865)
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


O.D.Y. May 31, 2010 03:55

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

euzinho May 31, 2010 05:23

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. (Post 260958)
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


O.D.Y. June 1, 2010 03:38

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

euzinho June 1, 2010 07:29

1 Attachment(s)
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. (Post 261103)
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. June 1, 2010 07:35

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..

euzinho June 1, 2010 09:07

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

O.D.Y. June 2, 2010 04:07

Why not, that should work....

euzinho June 2, 2010 04:19

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. (Post 261314)
Why not, that should work....


cheaklapomme June 3, 2010 08:56

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

almostafa67 August 3, 2010 02:22

rotation about z axis
 
2 Attachment(s)
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 :confused:
i will be thankful if you could help me out
looking forward to ur help.:)

almostafa67 August 5, 2010 09:48

update-dynamic-mesh failed. negative cell volume detected.
 
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 August 8, 2010 08:13

How to activate"spring-all-shapes"?
 
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...

cfdhydraulic September 22, 2010 10:06

butterfly valve
 
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);

AlbertoP June 28, 2011 09:32

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

Rahul123 June 27, 2012 03:11

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?

Vidit Sharma December 16, 2012 09:30

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

samcfd February 28, 2013 23:57

2D airfoil O Grid- negative volume
 
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

pradip.c1000 February 17, 2016 07:49

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.

arunraj May 14, 2016 03:03

1 Attachment(s)
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


All times are GMT -4. The time now is 09:02.