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/)
-   -   Define_profile udf not work correctly?! (https://www.cfd-online.com/Forums/fluent-udf/145906-define_profile-udf-not-work-correctly.html)

valahian1 December 15, 2014 03:08

Define_profile udf not work correctly?!
 
Hello everyone!
I have compiled an UDF for FLUENT 15.0 to test a velocity parabolic profile for inlet. But the DEFINE_PROFILE macro does not seem to work right. It takes the coordinates from the last face of the thread and it gives them to the second face (face no. 1). So, the velocity vector of the last face is always bigger that the vector before. Here is the code:

#include "udf.h"
DEFINE_PROFILE(inlet_velocity,t,i)
{
real x[ND_ND];
real a;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
a = f;
F_PROFILE(f,t,i) = 15.5-(a-5)*(a-5)/2;
printf("face no= %d\n", f);
printf("x= %f\n", x[0]);
printf("y= %f\n", x[1]);
}
end_f_loop(f,t)
}

And here is a part of the results:

face no= 0
x= 0.010000
y= 0.010500
face no= 1
x= 0.010000
y= 0.019500
face no= 2
x= 0.010000
y= 0.011500
face no= 3
x= 0.010000
y= 0.012500
...


The inlet starts at x=0.01; y=0.01 and stops at x=0.01; y=0.02 and has 10 faces.
I done something wrong? Or there is something wrong inside macro?
Thank you!

upeksa December 15, 2014 04:21

You have done something really odd here.

When you set a=f, you are using the face cell index, which don't have any kind of physical meaning, and then you take it to the F_PROFILE.

I guess what you meant was:

a=x[0], or a=x[1], or a=x[2].

Moreover, face_t is an integer, and a is a real number. In any case I wouldn't recommend that kind of programming, in any case a=(real)f, but anyway what you have done here is really unusual.

Cheers.

valahian1 December 15, 2014 05:39

Thank you upeksa for your answer.
Even I use

F_CENTROID(x,f,t);
a = x[1];
F_PROFILE(f,t,i) = 15.5-(a-5)*(a-5)/2;

the result is the same. And on the last face I receive the vector that should be on the face no 1 (second face in the thread).
I made this test on a 2D mesh to understand how FLUENT macros work.
The example from Help give me the same result for parabolic inlet velocity. And I don't know why the macro gives to the second face the coordinates of the last face. I have change the mesh and I receive the same result.
Thank you again.

pakk December 15, 2014 07:27

So you find that Fluent numbers your faces in this way:

0 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 1

This is apparently not what you expected. OK, no big deal. You now know that Fluent numbers faces in strange ways. The good thing is that you don't have to worry about that. Why would you care how Fluent numbers these faces?

I think your problem is that your parabolic profile (15.5-(y-5)*(y-5)/2) is wrong. This parabolic profile has its peak velocity at y=2.5, which is outside your domain. So I really doubt if that is what you want.

valahian1 December 15, 2014 10:46

Sorry @pakk, I forgot that I changed a=f to a=x[1].

But please take a look at this:

The function is:
http://www.cfd-online.com/Forums/att...1&d=1418657255

The code is:

#include "udf.h"
DEFINE_PROFILE(inlet_velocity,t,i)
{
real x[ND_ND];
real a;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
a = x[1];
F_PROFILE(f,t,i) = 25-((a*100-5)*(a*100-5)/1.5)*2;
printf("face no= %d\n", f);
printf("x= %f\n", x[0]);
printf("y= %f\n", x[1]);
}
end_f_loop(f,t)
}

and the result is:

http://www.cfd-online.com/Forums/att...1&d=1418657541

Why the function in EXCEL is different from FLUENT?
I don't understand.

The function is applied as x velocity inlet.

The coordinates of the centroid of faces make me crazy too:
f0: 0.01,0.0105 / f1: 0.01,0.0195 / f2: 0.01,0.0115 / f3: 0.01,0.0125 ...
and then goes right.
The centroids correspond to faces 0-9-1-2-3-4-5-6-7-8.

Thanks!

ghost82 December 15, 2014 11:38

1 Attachment(s)
You should obtain the profile in the attached picture..what do you obtain?

valahian1 December 15, 2014 11:42

@ghost82
Did you use the equation from the last my post? That with the graphic in EXCEL?

ghost82 December 15, 2014 11:44

equation is:
25-((a*100-5)*(a*100-5)/1.5)*2

a=y
y [0.01;0.02]

chart is made in excel.

valahian1 December 15, 2014 11:48

But y[0.01;0.09]

ghost82 December 15, 2014 11:53

1 Attachment(s)
Quote:

Originally Posted by valahian1 (Post 524050)
But y[0.01;0.09]

Previously you wrote:
Quote:

The inlet starts at x=0.01; y=0.01 and stops at x=0.01; y=0.02
You should have the parabolic profile - equation 25-((a*100-5)*(a*100-5)/1.5)*2

Again post a picture of what do you obtain.

valahian1 December 15, 2014 11:56

1 Attachment(s)
And the results from fluent, for faces centroids coordinates, are;

http://www.cfd-online.com/Forums/att...1&d=1418662454

valahian1 December 15, 2014 11:57

sorry for that 0.02

ghost82 December 15, 2014 11:57

And so? :)
You want a x velocity profile function of y coordinates; post a chart of y vs x-velocity.

valahian1 December 15, 2014 12:18

@ghost82

OK, sorry

Here is the eq. 25-((a*337-5)*(a*337-5)/1.01)*2
for a=x[1] meaning y coordinates

Here is the graph in excel:

http://www.cfd-online.com/Forums/att...1&d=1418663787

ghost82 December 15, 2014 12:22

Nick, stop a moment please :)
You changed the equation 3 times in a thread...

What is the profile you want to impose?

And post a picture of fluent chart: y coordinate versus x-velocity (at the inlet).

PS: there's nothing wrong in centroids values: face numbers, x coordinates and y coordinates are reported.

valahian1 December 15, 2014 12:27

I want a parabolic profile to have at the inlet the vectors of the velocity bigger at the center of the inlet and smaller in the proximity of walls. I think I'm desperate for now because I received a lot of errors from compiler, fluent and so on ...

valahian1 December 15, 2014 12:38

1 Attachment(s)
@ghost82

Finnaly I calm down and I succeed.
Here is the inlet image

http://www.cfd-online.com/Forums/att...1&d=1418664864



Thank you for your patience with me!


All times are GMT -4. The time now is 07:48.