CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   Boundary layer calculation, scripting in Post. (

a.ob March 9, 2011 06:39

Boundary-layer thickness calculation. Scripting in Post.
Hey everyone,

I'm currently working on on way to calculate the thickness of the momentum boundary-layer as well as the boundary layer of an airfoil. After reading around about the possibilites to do this in Post I've realised that there's no easy way to do this other than writing a script. What I want the script to do is sweep over the midspan of the airfoil creating lines normal to the surface and then saving necessary data to a file. I can then use this data in MATLAB to calculate the thickness and plot it against the relative position on the airfoil.

So far I've used a script that creates a polyline along the midspan on the upper side of the airfoil and then creates a file containing x,y,z coordinates as well at the normal X and normal Y direction for 100 points along the line. (I should mention that the scripting is done in PERL)

I then write a new script that looks something like this


! $cnt=0
! open(IN, "<./Axial-Profile_vane-0_sst_002.csv");
! while (defined ($line = <IN>)) {;
!    @coord = split(',' $line);
!    $coord[4] = $coord[4] * -1;
! $cnt = $cnt +1;
! print "$coord[0] \n";
PLANE: PlaneNorm # Here I create a plane with the coordinates and normal directions from axial-profile.
CONTOUR: Contour Z #Here I create a contour plot on PlaneNorm with 3 contours in z-direction.
POLYLINE: Polyline1 #Here I create a polyline in the normal direction at the midspan by creating it from Contour Z and contour level 2
! $LineName = "Polylines/Line.".$cnt.".csv";
EXPORT: #Here I export the x- and y-coordinates as well as the velocity of Polyline1 to the file $LineName
! }
! close(IN)

The script above sweeps over the surface of the airfoil creating 100 polylines normal to the surface and then creates 100 files with the data I need to determine the B-L thickness in MATLAB.

However... and this is where my problem is. The polylines that are created goes in both directions. That is, in the normal direction on both the upper AND lower side of the airfoil.

What I wonder is if there's any easy way of manipulating the polylines so they're only created on the upper side of the airfoil and not across the entire domain.

One possible solution I've thought of is to compare the actual y-coordinate in axial_profile each loop to the y-coordinates on each row in $LineName. Then if the coordinates for the polyline are found to be below that from axial_profile, delete those rows. Thus giving me a file with only the points on the upper side of the airfoil. Is this something that's possible? and if so, how could I do it?

My knowledge in programming is a bit limited and especially in PERL so any help will be greatly appreciated.


a.ob March 11, 2011 09:03

I managed to come up with a solution for my problem by introducing a second while-loop within the while-loop. This loop went through all the lines of coordinates in the polyline file and compared the y-coordinate with the y-coordinate in the axial_profile file and then saved them to a new file. Thus giving me 100 polylines normal to the surface at the midspan on the suction side of the airfoil. All that's left now is to contruct a MATLAB program that calculates the B-L thickness from the data.

If anyone is interested in knowing in more detail how I made the script, just send me a pm :)


iffy March 30, 2011 15:18

I am also working on the same problem. I have to calculate boundary layer characteristics of 2D airfoil (BL thickness, Displacement thickness and momentum thickness). So far I am not able to calculate them but I have an idea to calculate BL thickness which is simple but I am not sure whether is correct or not. Anyways I will share it.
To calculate BL thickness:
1) Plot velocity contours in CFX-Post. For the range use option "Value List". For the values use two values of "0 and 0.99*U freestream (means the second value should be the 99% of the free stream velocity).
2) Create Polyline (say polyline 1). For method use option "From Contour". For the contour select the velocity contour and for the level select 2. This will create a polyline at 99% of the free stream velocity in the whoyle domain.
3) To extract the values of the BL, insert a Chart. For location' specify the polyline 1. For X variable use variable from the list of variables "X" and for y variable use "Y" variable from the list. This will give the coordinates of the BL.

This method seems to work but I get some some strange values near the leading edge of the airfoil.



a.ob April 1, 2011 03:40

Hi Irfan,

To calculate the displacement and momentum thickness I had to use Matlab where I imported the data from the lines normal to the surface that my script created. Each file contained X- and Y-coordinates along the line together with Total and Static Pressure. The stream situation in my simulations lacked real free stream conditions everwhere so I had to calculate my velocity from,
v= sqrt(2*(P0-Pstat,wall)/rho).
Because of this I didn't get very good results from your solution to finding 0,99*free stream velocity but I did get it to work very well for the flow over a flat plate. So thank you!
I still haven't managed to figure out how to calculate the BL thickness in matlab but if you want some hints on how to calculate the displacement and momentum thickness, just let me know :)


iffy April 1, 2011 11:47

Hi Andreas,

It will be very helfpul, if you can share how to calculate momentum and displacement thickness. Actually I was trying to calculate it in some easy way, but guess there is no easy way to do. Can you give some info about it?
Thanks in advance.


a.ob April 5, 2011 04:50

I sent you a PM :)


kiddmax October 8, 2013 05:28

Hello Andreas,

Currently I am working on calculating the displacement thickness and momentum thickness on the airfoil. Could you please give me some hints to calculate it? and how to creat line normal to the airfoil surface? Thank you so much!

Best regards,

venkat_aero2007 August 20, 2014 11:18

Shape factor
I am analyzing transition point over NACA 4412 airfoil at low Reynolds number using Transition Kw-SST model. I am using FLUENT for simulation. I dont know how to plot Shape factor from FLUENT result. I know that Shape factor is the displacement thickness divided by moment thickness. I read in a post that velocity profile can be obtained by creating a line perpendicular to the surface at the point of interest and with the help of that velocity variation can be plotted.

I don't know how to plot shape factor in fluent. Can anybody please help me in this regard.

All times are GMT -4. The time now is 19:49.