CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF of shear flows - Just need a little little help (http://www.cfd-online.com/Forums/fluent/90298-udf-shear-flows-just-need-little-little-help.html)

yannossss July 6, 2011 11:58

UDF of shear flows - Just need a little little help
 
Hey guys
I've got a little problem about my UDF program to simulate shear flow in Fluent.
I finally managed to write the UDF program but there is a little mistake somewhere and I can't manage to fix it.

So the geometry of my problem is displayed here -> http://i1129.photobucket.com/albums/...inderinbox.jpg

As you can see I want the shear flow to act on the z-axis direction.

My UDF program is written as follows:

#include "udf.h"

DEFINE_PROFILE(yann_x_velocity, thread, position)
{
real x[ND_ND]; /* this will hold the position vector */
real z;
real u0=1.0;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
z=x[1];
F_PROFILE(f, thread, position) =1.0+20.0*z;
}
end_f_loop(f, thread)
}


Now the problem in Fluent is:

When I plot the X velocity profile following a line created on the z-axis, the graph given is http://i1129.photobucket.com/albums/...annossss/1.jpg but this is not the solution I want.

On another hand when I plot the X velocity profile following a line created on the y-axis, the graph obtained is http://i1129.photobucket.com/albums/...annossss/2.jpg and this is the graph I'd like to get BUT when I plot the X velocity profile following the line created on the z-axis.

I have tried to modify the UDF file but nothing has worked. I'm pretty sure I am very close to the solution but I didn't mange to find and fix the mistake.

So if anyone could give me a little help I would really much apprecite it.

Thanks for your time guys, I hope you got what my problem is.

Yann

Galileo July 6, 2011 12:24

Quote:

Originally Posted by yannossss (Post 314962)

real x[ND_ND]; /* this will hold the position vector */
real z;
real u0=1.0;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
z=x[1];
F_PROFILE(f, thread, position) =1.0+20.0*z;
}
end_f_loop(f, thread)
}


Yann

What I guess is wrong is z=x[1];
I think it should be z=x[3]; to mean z=zaxis because z=x[1]; means z=x axis.
At the interface, x=0 in your 3D rectangular geometry.

Notice that the velocity is constant meaning the face coordinate is x=0.

The plot direction, I think, should be x=1, z=0, y=0 ie in the x-direction in your yannossss/1.jpg not z=1.

I suppose all those by using my left hand as the box. Thumb=z axis, first finger=y axis,second finger= x axis, based on your Squarecylinderinbox.jpg

Hope am not confusing you ...lol

Please confirm am right or wrong.

yannossss July 6, 2011 13:21

Thank you very much for the reply unfortunately it does not work.

I also think the mistake comes from the line "z=x[1];"

However I made a little mistake on the Squarecylinderinbox.jpg and the right geometry is http://i1129.photobucket.com/albums/...oxmodified.jpg but I don't think it changes the problem.

When I plot the X velocity with the plot direction being as you advised me x=1, y=0 and z=0 following the line created on the z-axis it doen't give anything. I mean nothing is plotted.

When I do the same but following the line created on the y-axis it gives this http://i1129.photobucket.com/albums/...annossss/3.jpg

Hope you're not confused too and still have some ideas in the back of your mind.

Galileo July 6, 2011 15:48

1 Attachment(s)
Quote:

Originally Posted by yannossss (Post 314975)
Thank you very much for the reply unfortunately it does not work.

I also think the mistake comes from the line "z=x[1];"

However I made a little mistake on the Squarecylinderinbox.jpg and the right geometry is http://i1129.photobucket.com/albums/...oxmodified.jpg but I don't think it changes the problem.

When I plot the X velocity with the plot direction being as you advised me x=1, y=0 and z=0 following the line created on the z-axis it doen't give anything. I mean nothing is plotted.

When I do the same but following the line created on the y-axis it gives this http://i1129.photobucket.com/albums/...annossss/3.jpg

Hope you're not confused too and still have some ideas in the back of your mind.




I think the system in Fluent is x=x[0],x[1],x[2] and not 1,2,3

so it should be:

real x[ND_ND]; /* this will hold the position vector */
real z;
real u0=1.0;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
z=x[2];
F_PROFILE(f, thread, position) =1.0+20.0*z;
}
end_f_loop(f, thread)
}



See the file for my understanding of your model. I like to know if it works.
Make sure your axis system is right in Fluent see the x,y,z system and be sure you bind the BC UDF correctly.

yannossss July 9, 2011 07:01

Problem solved
 
Hey lad I solved my problem.

So the problem was the cartesian system. In fact the udf is written for my mind with the catesian system I always learnt, meaning: with the right hand, thumb pointing the right designng the x-axis, first finger pointing up designing the y-axis and second finger pointing myself designing the z-direction. It is how Gambit is set and Fluent is also set that way.

The problem comes from the reading of the udf file by Fluent. I don't know why but I realised that when Fluent reads the udf file the cartesian system used changes and is defined as: still with your right hand, thumb pointing the right designing the x-axis, first finger pointing in front of you designing the y-axis and second finger pointing up designing the z-axis.

Which means that on the udf file, the "z" is read by Fluent as a "y". So in Gambit I just rotated the whole geometry by 90 around the x-axis and modify the equation in the udf file and now when I plot the x-velocity in the y direction (y direction that was the z before of course) it gives me what I'm looking for.

Tell me if you understood and thank you very much to have replied quickly to my post to help me.

I wish you all the best. Bye bye

Galileo July 11, 2011 07:11

Quote:

Originally Posted by yannossss (Post 315438)
Hey lad I solved my problem.

So the problem was the cartesian system. In fact the udf is written for my mind with the catesian system I always learnt, meaning: with the right hand, thumb pointing the right designng the x-axis, first finger pointing up designing the y-axis and second finger pointing myself designing the z-direction. It is how Gambit is set and Fluent is also set that way.

The problem comes from the reading of the udf file by Fluent. I don't know why but I realised that when Fluent reads the udf file the cartesian system used changes and is defined as: still with your right hand, thumb pointing the right designing the x-axis, first finger pointing in front of you designing the y-axis and second finger pointing up designing the z-axis.

Which means that on the udf file, the "z" is read by Fluent as a "y". So in Gambit I just rotated the whole geometry by 90 around the x-axis and modify the equation in the udf file and now when I plot the x-velocity in the y direction (y direction that was the z before of course) it gives me what I'm looking for.

Tell me if you understood and thank you very much to have replied quickly to my post to help me.

I wish you all the best. Bye bye


Its good to know you have solved your problem. I don't use Gambit. From what you noticed, it is therefore important to see the geometry coordinate system as displayed in Fluent (irrespective of the meshing software).
Good luck to you.


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