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

Define_profile udf not work correctly?!

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ghost82

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 15, 2014, 03:08
Default Define_profile udf not work correctly?!
  #1
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
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!
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 04:21
Default
  #2
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
upeksa is on a distinguished road
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.
upeksa is offline   Reply With Quote

Old   December 15, 2014, 05:39
Default
  #3
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
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.
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 07:27
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   December 15, 2014, 10:46
Default
  #5
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
Sorry @pakk, I forgot that I changed a=f to a=x[1].

But please take a look at this:

The function is:


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:



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!
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 11:38
Default
  #6
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
You should obtain the profile in the attached picture..what do you obtain?
Attached Images
File Type: png velocity.png (42.1 KB, 4 views)
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   December 15, 2014, 11:42
Default
  #7
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
@ghost82
Did you use the equation from the last my post? That with the graphic in EXCEL?
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 11:44
Default
  #8
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
equation is:
25-((a*100-5)*(a*100-5)/1.5)*2

a=y
y [0.01;0.02]

chart is made in excel.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   December 15, 2014, 11:48
Default
  #9
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
But y[0.01;0.09]
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 11:53
Default
  #10
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Quote:
Originally Posted by valahian1 View Post
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.
Attached Images
File Type: png velocity.png (60.6 KB, 5 views)
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   December 15, 2014, 11:56
Default
  #11
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
And the results from fluent, for faces centroids coordinates, are;

Attached Images
File Type: jpg result.JPG (32.4 KB, 32 views)
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 11:57
Default
  #12
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
sorry for that 0.02
valahian1 is offline   Reply With Quote

Old   December 15, 2014, 11:57
Default
  #13
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
And so?
You want a x velocity profile function of y coordinates; post a chart of y vs x-velocity.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   December 15, 2014, 12:18
Default
  #14
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
@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:

valahian1 is offline   Reply With Quote

Old   December 15, 2014, 12:22
Default
  #15
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
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 likes this.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   December 15, 2014, 12:27
Default
  #16
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
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 is offline   Reply With Quote

Old   December 15, 2014, 12:38
Default
  #17
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
@ghost82

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





Thank you for your patience with me!
Attached Images
File Type: jpg vectors1.JPG (41.8 KB, 33 views)

Last edited by valahian1; December 16, 2014 at 13:05.
valahian1 is offline   Reply With Quote

Reply

Tags
define_profile, fluent, macro, udf


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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
udf doesn't work blaid FLUENT 0 March 6, 2012 12:29
the udf has been hooked to the fluent successfully,but it does not work! hugeforest Fluent UDF and Scheme Programming 1 July 8, 2011 04:31
Timestep UDF not work peaker007 Fluent UDF and Scheme Programming 0 April 28, 2011 12:10
UDF for wall slipping HFLUENT Fluent UDF and Scheme Programming 0 April 27, 2011 12:03


All times are GMT -4. The time now is 01:22.