|
[Sponsors] |
December 15, 2014, 04:08 |
Define_profile udf not work correctly?!
|
#1 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
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! |
|
December 15, 2014, 05:21 |
|
#2 |
Member
Join Date: Jul 2013
Posts: 80
Rep Power: 13 |
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. |
|
December 15, 2014, 06:39 |
|
#3 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
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. |
|
December 15, 2014, 08:27 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 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. |
|
December 15, 2014, 11:46 |
|
#5 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
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! |
|
December 15, 2014, 12:38 |
|
#6 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
You should obtain the profile in the attached picture..what do you obtain?
__________________
Google is your friend and the same for the search button! |
|
December 15, 2014, 12:42 |
|
#7 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
@ghost82
Did you use the equation from the last my post? That with the graphic in EXCEL? |
|
December 15, 2014, 12:44 |
|
#8 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
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! |
|
December 15, 2014, 12:48 |
|
#9 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
But y[0.01;0.09]
|
|
December 15, 2014, 12:53 |
|
#10 | |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Previously you wrote:
Quote:
Again post a picture of what do you obtain.
__________________
Google is your friend and the same for the search button! |
||
December 15, 2014, 12:56 |
|
#11 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
And the results from fluent, for faces centroids coordinates, are;
|
|
December 15, 2014, 12:57 |
|
#12 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
sorry for that 0.02
|
|
December 15, 2014, 12:57 |
|
#13 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
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! |
|
December 15, 2014, 13:18 |
|
#14 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
@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: |
|
December 15, 2014, 13:22 |
|
#15 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
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.
__________________
Google is your friend and the same for the search button! |
|
December 15, 2014, 13:27 |
|
#16 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
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 ...
|
|
December 15, 2014, 13:38 |
|
#17 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
@ghost82
Finnaly I calm down and I succeed. Here is the inlet image Thank you for your patience with me! Last edited by valahian1; December 16, 2014 at 14:05. |
|
Tags |
define_profile, fluent, macro, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
udf doesn't work | blaid | FLUENT | 0 | March 6, 2012 13: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 05:31 |
Timestep UDF not work | peaker007 | Fluent UDF and Scheme Programming | 0 | April 28, 2011 13:10 |
UDF for wall slipping | HFLUENT | Fluent UDF and Scheme Programming | 0 | April 27, 2011 13:03 |