CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Moving wall with velocity profile (https://www.cfd-online.com/Forums/fluent/86619-moving-wall-velocity-profile.html)

Tobard March 28, 2011 12:53

Moving wall with velocity profile
 
Hi everyone!

I need to study a transient flow inside a closed cylinder which is starting to rotate. It seems impossible to put a velocity profile instead of a constant value under rotating wall boundary conditions with Fluent. Is there another way to do this? Is there somebody here who already tried such a transient simulation?

Thank you very much for your help!

Amir March 28, 2011 13:14

Hi,
if you try components option in wall boundary conditions, you can impose any velocity profile by a UDF.

Tobard March 28, 2011 13:44

Quote:

Originally Posted by Amir (Post 301242)
Hi,
if you try components option in wall boundary conditions, you can impose any velocity profile by a UDF.

Thank you for your answer. I tried this but I would like to input a rotational speed and the only velocity components that are displayed are X, Y and Z components in m/s... Is it possible to change it in order to work in cylindrical coordinates for example? I haven't found anything satisfactory so far.

Thank you!

Amir March 28, 2011 16:01

note that you can implement coordinates of surface elements. so you can use a trigonometric functions in your UDF to obtain Cartesian components from rotational speed.

Tobard March 29, 2011 11:15

Dear Amir,

Ok, I am trying to use these UDF. Since I am not really used to this option, it is difficult for me to understand how to implement coordinates of surface elements, as you said. Would it be possible to have an example of the kind of script you was thinking about? I haven't found anything similar in Fluent UDF Guide.

Thank you very much for your help!

Tobard.

Amir March 29, 2011 11:41

Hi,
it's something like this (as a part of UDF):
Quote:

real x[ND_ND],xf,yf,zf,theta;
F_CENTROID(x,f,t);
xf=x[0];
yf= x[1];
zf= x[2];
theta=atan(yf/xf);
F_PROFILE(f,t,i) = R*omega*sin(theta);
it can be used for x-component. (check it's sign and ...)

Tobard March 30, 2011 12:20

Hi,

Following your advice and trying to understand UDF philosophy, I have written the following function (I think I will have to do 2 different files in order to fill both X and Y velocity component fields in Fluent boundary conditions later, but it is a global base):
Quote:

#include"udf.h"
DEFINE_ADJUST(try3,d)
{
Thread *tf;
face_t f;
real time;
time = CURRENT_TIME;
real x[ND_ND];
real xf, yf;
real omega;
omega = 2*time;
begin_f_loop(f,tf)
{
if (BOUNDARY_FACE_THREAD_P(tf))
{
F_CENTROID(x,f,time);
xf = x[0];
yf = x[1];
F_U(f,time) = -omega*yf; /* For x-component */
F_V(f,time) = omega*xf; /* For y-component */
}
}
end_f_loop(f,tf)
}
Could you please take a look at this? The purpose is to change wall rotational velocity at each time step, and I am not sure my code is correct.

Besides when I try to interpret this with Fluent, I get these errors:
Quote:

Error: [...] line 8: parse error.
Error: [...] line 9: parse error.
Error: [...] line 10: parse error.
Error: [...] line 11: omega: undeclared variable
and I don't understand why!?

Thank you very much for your help!

Tobard

Amir March 30, 2011 16:01

Hi,
I proposed you these changes:
Quote:

#include "udf.h"
#include "math.h"
DEFINE_PROFILE(x_velocity,thread,position)
{
face_t f;
real time = CURRENT_TIME;
real x[ND_ND],theta;
real R=1.0;
real omega=2.0*time;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
theta=atan(x[1]/x[0]);
F_PROFILE(f, thread, position) = R*omega*sin(theta);
}
end_f_loop(f, thread)
}
I've compiled this without any error.
you're right, you need another UDF for y velocity which is similar to above.

regards,

Tobard March 30, 2011 17:19

Thank you, it helps me much! I just would like to understand some points:

- My study needs to change ONLY wall (boundary) velocity (and then observe inertia and viscosity action into the fluid). Does your function really allow that? Using it under boundary conditions menu would then only apply it on boundary faces?

- Is it better to use F_PROFILE instead of F_U or F_V? I am afraid that F_PROFILE may change both X and Y velocity components although I need to change them one by one. (Furthermore F_U and F_V would allow me to not use trigonometrical functions, writing u= -omega*y and v= omega*x)

- Does Fluent accept using several interpreted UDFs at the same time? Or do I have to compile them? Thank you again, I think it will work now!

Regards,
Tobard

Amir March 31, 2011 03:35

Hi,

Quote:

- My study needs to change ONLY wall (boundary) velocity (and then observe inertia and viscosity action into the fluid). Does your function really allow that? Using it under boundary conditions menu would then only apply it on boundary faces?
it depends on where you'll hook this UDF, if you hook that over wall boundary, it would change wall velocities.

Quote:

- Is it better to use F_PROFILE instead of F_U or F_V? I am afraid that F_PROFILE may change both X and Y velocity components although I need to change them one by one. (Furthermore F_U and F_V would allow me to not use trigonometrical functions, writing u= -omega*y and v= omega*x)
I don't agree with you, in both cases you need to use trigonometric functions but here, you can simplify your relations. i.e. :
R*omega*sin(theta)=R*omega*sin(atan(y/x))=y*omega
these relations are applicable to both procedures. note that using DEFINE_PROFILE for setting boundary conditions is more conservative and reliable than using other functions.

Quote:

- Does Fluent accept using several interpreted UDFs at the same time? Or do I have to compile them? Thank you again, I think it will work now!
that's one of the restrictions of interpreted UDFs. I proposed you using compiled one.

Regards,
Amir

Tobard April 4, 2011 10:22

Hi,

I post this last message to thank you: my simulation is now working, using DEFINE_PROFILE just as you said.
A little feedback: working with direct coordinates rather than using trigonometrical functions avoids sign problems.

Regards,

Tobard

Tobard April 13, 2011 15:10

Hi everybody!

I come here again because I encountered some new difficulties: I succeed in putting a profile law making the wall of my 2D cylinder rotate.

Now I would like to improve my model by dividing my cylinder in several zones (adding a wall along portion of diameter, basically). The whole assembly is not rotating as expected because "you cannot use the moving wall condition to model problems where the wall has a motion normal to itself. FLUENT will neglect any normal component of wall motion that you specify using the methods below." (Fluent User Guide).

A moving reference frame would allow me to make my walls rotate. But is it possible to hook a UDF to a moving reference frame (I see no available field for that)? Is there another way to do it?

Thank you so much for your help!

Tobard

Amir April 14, 2011 15:23

Hi,
I've done such cases by implementation of dynamic mesh, in FLUENT 6.3 you can't use MRF for arbitrary motions(as you said) but it may be included in latest versions.

Tobard April 14, 2011 15:42

I work on Fluent 12.0.1 or 12.1 and it seems not to be better. Do you think a moving mesh could be a solution? My geometry is similar to a disk split into to parts...

Tobard

Amir April 15, 2011 10:47

certainly, moving mesh can help you to impose normal velocity to walls. I'll appreciate any other ideas ...

Tobard May 3, 2011 14:41

Dear Amir,

Do you know where I could find samples or UDF functions close to my problem? I really don't see how to write (and hook) a UDF making my walls move and it is really difficult to find any help on the Internet.

Any concrete suggestion would be appreciated...

Thank you very much.

Tobard

Amir May 4, 2011 15:22

Hi,
I wrote a UDF which rotate a wall but you can change that easily; here you are:
Quote:

#include "udf.h"
#include "stdio.h"
#include "math.h"
#define pi 3.1415
#define amp 0.174
#define freq 0.75
real w=2*pi*freq;
DEFINE_GRID_MOTION(motion,domain,dt,time,dtime)
{
Thread *tf = DT_THREAD(dt);
face_t f;
Node *v;
real theta,a,b;
int n;
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);
theta=(-1)*amp*w*cos(w*time)*dtime;
a=cos(theta)*NODE_X(v)-sin(theta)*NODE_Y(v);
b=sin(theta)*NODE_X(v)+cos(theta)*NODE_Y(v);
NODE_X(v)=a;
NODE_Y(v)=b;
}
}
}
end_f_loop(f,tf);
}

Tobard May 5, 2011 19:03

Dear Amir,

What a relief to receive your answer! It greatly helped me and my problem is solved: it rotates!

I sincerely thank you!

Tobard

Tobard May 16, 2011 11:19

Dear Amir,

Sorry for coming to you again...
My simulations with Dynamic mesh give me strange results. Do you know how Fluent manage the transition between two time steps? The velocity is well defined at the boundary but seems not able to diffuse into the whole fluid zone...!
I tried with a DEFINE_CD_MOTION function instead of the DEFINE_GRID_MOTION one with no improvement. So I really don't know where this problem comes from.

Is there restrictions in the use of Dynamic mesh?
Have you ever encountered such an issue?

Thank you again for your help!

Tobard

Amir May 16, 2011 12:14

Hi Tobard,
pay attention to locations where you hooked this UDF for. In other words, in dynamic zones, set e.g. walls, define interior and other rotating boundaries except the fluid zones.

regards,

Amir

Tobard May 16, 2011 13:44

1 Attachment(s)
Hi Amir,

Thank you for this advice, I've checked: my dynamic zones are OK.

To be more precise about my problem, please find attached a picture of the velocity distribution I got.
The flow is laminar, so the velocity distribution vs the radius has to be linear, as it is when I use moving wall option. I cannot understand why there is a difference since I haven't changed any parameter when applying Dynamic mesh.
Another strange thing is the fact that the "colored layer" becomes thinner if I reduce the time step.
Have you any idea?

Thanks!

Tobard

Amir May 16, 2011 16:29

Hi,
the velocity profile would be linear if you impose a constant angular velocity. (is it your case?)
it seems that the wall momentum has diffused in the domain but you have to have much more time steps to reach the linear profile; let it advances in time.
Also check that whether your wall velocity is correct or not.

Tobard May 16, 2011 17:29

Hi,

The angular velocity is constant after 2 seconds.
The problem is that even if I wait for more timesteps this profile doesn't change any more, which is physically impossible. I could have sent the same picture at 4 or 5 seconds, it would have been the same! And if I reduce the time step, this profile becomes thinner...:confused:
Besides, the results that I am able to have using another method (moving wall) are quite different for the same flow time. I really don't understand why moving mesh give me such inaccurate results. :(

Thank you for your reply.

Tobard

Amir May 17, 2011 09:12

Hi,
Post your UDF and I'll check that.

Tobard May 17, 2011 16:50

Hi!

It is a very basic UDF:
------------------------------
#include"udf.h"
DEFINE_CG_MOTION(rot_cg, dt, velocity, omega, time, dtime)
{
if(time < 2){
omega[2]=75*time;
}
else{
omega[2]=150;
}
}
------------------------------
Thank you again!

Tobard

Amir May 18, 2011 15:19

Hi,
I have suggestion; consider a point on the boundary and export results during different time steps and check whether it obeys UDF or not.

Tobard May 18, 2011 15:46

Hi,

I tried this and this is all right. Points on the boundary are the only ones that have a correct velocity at each time step... That's why it seems really weird to have an inaccurate velocity inside the zone...

Thanks!

Amir May 19, 2011 02:01

Hey,
double check your boundary conditions, i.e. in fluid zone, you have to set stationary in motion type and in wall zones, set stationary wall (relative to adjacent cell zones)

Tobard May 19, 2011 15:31

Dear Amir,

Everything is already stationary... Does it work for you? I don't see what is wrong... :(

Amir May 19, 2011 15:56

Have you ever checked that with DEFINE_GRID_MOTION macro?

Tobard May 19, 2011 17:11

Yes, that was my initial try. And that's because it didn't work that I decided to use DEFINE_CG_MOTION... (Yeah, not really logical process order, I know...). So I have encountered the same problem with both methods!

musahossein December 6, 2011 15:10

what is meant by movingWallVelocity?
 
Can anyone please tell me what the keyword movingWallVelocity does in OpenFoam? My question pertains to its use in the U file in sloshingTank2D in the OpenFOAM tutorial. The walls of the tank are defined as patch type walls and the front and back walls are defined as empty. IN the velocity (U) file, all the walls are defined as movingWallVelocity. Does this mean that the walls are moving with the velocity or the mesh?

Amir December 6, 2011 15:17

Quote:

Originally Posted by musahossein (Post 334913)
Can anyone please tell me what the keyword movingWallVelocity does in OpenFoam? My question pertains to its use in the U file in sloshingTank2D in the OpenFOAM tutorial. The walls of the tank are defined as patch type walls and the front and back walls are defined as empty. IN the velocity (U) file, all the walls are defined as movingWallVelocity. Does this mean that the walls are moving with the velocity or the mesh?

Dear friend,

As you know, this not OpenFOAM forum!!! but I've had experiences with this. You can move your boundaries via dynamic mesh technique with this BC.

Bests,

musahossein December 6, 2011 16:11

Quote:

Originally Posted by Amir (Post 334915)
Dear friend,

As you know, this not OpenFOAM forum!!! but I've had experiences with this. You can move your boundaries via dynamic mesh technique with this BC.

Bests,

Thanks and sorry for not paying attention to where it was being posted.

angelicapeygo June 3, 2013 08:37

udf question...
 
Dear Friends;
I want to ask you about my problematic UDF:(
I want to write a UDF in order to define the temperature distribution on a side wall.
I am very ne about UDF writing and can not create what I really want.
My aim is to define just;
T=938+40*y
it is the temperature change on the wall. there is no other BC for my case.
could you please help me??*Thank you very much.

Amir June 3, 2013 09:45

Quote:

Originally Posted by angelicapeygo (Post 431630)
Dear Friends;
I want to ask you about my problematic UDF:(
I want to write a UDF in order to define the temperature distribution on a side wall.
I am very ne about UDF writing and can not create what I really want.
My aim is to define just;
T=938+40*y
it is the temperature change on the wall. there is no other BC for my case.
could you please help me??*Thank you very much.

Hi,

Refer to the "DEFINE_PROFILE" macro in the UDF manual.

Bests,

Mahdiabt January 30, 2015 12:22

Hi guys

I want to simulate an oscillating wall in a cylinder in a tangential direction of the wall just could any one help me to figure out how can I do this?? Do I need to use dynamic mesh for this problem??

Best Regards
Mahdi

sanjeetlimbu April 9, 2015 09:54

3 Attachment(s)
I am trying to simulate compression stroke in 2D axisymetric mode. using rigid motion.
I tried using the profile- in cylinder, i took data point for time vs velocity at y and notepad write in profile defone. the piston boundary moves but is not 254mm distance i needed (even though i got 254 in matlab with that points)

I used the udf option but i am geting warning error.

Can you please tell what is wrong in either profile or udf i attached.
#include "udf.h"
DEFINE_CG_MOTION(oscillate, dt, vel, omega, time, dtime)
{
Thread *t;
face_t f; /* define the variables */

t = DT_THREAD(dt); /* get the thread pointer for which the motion is defined */

/* if (!Data_Valid_P())
/* return; /* check if the values of the variables are accessible before you compute the function */

begin_f_loop(f, t) /* loop over each face in the zone to create an array of data */
{
if (time <= 0.012)
vel[0] = (637* time); /* define the velocity of the moving zone---*/
else if (0.012 < time < 0.019)
vel[0] = vel[0] + (2.4* time);
else if (0.019 < time < 0.027)
vel[0] = 14;
else if (0.027 < time < 0.03)
vel[0] = vel[0] - (6.5*time);
else if (0.03 < time)
vel[0] = 0;
}
end_f_loop(f, t)
}


thanks
sanjeet


All times are GMT -4. The time now is 10:54.