You are on page 1of 14

ADVANCED COMPUTATIONAL

FLUID DYNAMICS (ME 687)


MINI-PROJECT 1 (ALGEBRAIC GRID GENERATION
USING TFI)

Name: Eldwin Djajadiwinata


Student ID: 434107763
Lecturer: Dr. Shereef Sadek

Advanced Computational Fluid Dynamics ME687


Mini-Project 1
First Semester 1435/1436
Due date Thursday October 19th

Write a computer program to generate an O-grid to discretize the domain shown in Figure 1
using Transfinite Interpolation. The domain consists of the outer boundary
and inner
boundary which is a Karman-Treffetz airfoil.

Figure 1: Physical Domain

The airfoil surface coordinates are calculated with the attached function. Your computer code
must accept as input the number of points
along the airfoil normal and tangential
directions, respectively.

Note: All submitted work should be entirely yours. Include source code in your report.

Solution:

1. Brief Introduction to TFI Transformation


Before the code is presented, some concepts will be presented regarding the Transfinite
Interpolation (TFI) transformation which will be used to generate the grid.
Transfinite Interpolation (TFI) transformation is one of the algebraic methods to create a
structured grid. TFI transformation is obtained in three steps:
1. Linear interpolation (unidirectional interpolation)
2. Composite mapping
3. Boolean summation
These will be explained one by one as follows.

1. Linear interpolation (unidirectional interpolation)


Suppose we have/know a transformation function/mapping function from a physical
domain in x and y coordinate into unit square computational domain in xi and eta coordinate or
vice versa (i.e., from unit square computational domain to physical domain).

Figure 2: Mapping from computational domain into physical domain or vice versa

Utilizing this mapping function we can use unidirectional interpolation to generate the
internal grid in the physical domain. However, unidirectional interpolation alone cannot create
the correct shape of the boundary of the physical domain especially if the boundary has curved

shape. This is because unidirectional interpolation will generate a straight boundary instead of
the original curved boundary AB, BC, CD, and DA. This statement will be explained in more
detail in the following paragraphs.
Firstly, let us generate another transformation, , to map points from the
computational domain into the physical domain which will linearly interpolate the values of
between
and
at each value of . The has the following form (Eq. (1)).

(1)

By means of this linear interpolation we will obtain a grid on the physical domain which shows
the curved-boundary AB and CD correctly, while create an incorrect straight-line for boundaries
AC and BD as shown in Figure 3.

Figure 3: The physical domain obtained by transformation

Secondly, let us again consider another transformation, , which also maps points from
the computational domain into the physical domain which linearly interpolates the values of ,
instead of the values of , between
and
at each value of .

(2)

This mapping function will result in, in contrary to the previous mapping, the correct curvedboundary for AC and BD, while give incorrect straight line for boundaries AB and CD
(see Figure 4).

Figure 4: The physical domain obtained by transformation

Thus, it can be concluded that a transformation based on a unidirectional interpolation


( and ) will not work perfectly. In order to remedy this problem, one needs to utilize both
transformations ( and ) in conjunction with composite mapping and Boolean summation.

2. Composite mapping
By applying composite mapping using and , one will obtain a physical region which
has correct vertices (A, B, C, and D) but with all boundaries replaced by straight lines instead of
the actual curved-boundaries. The composite mapping function and the resulting physical
domain can be seen below (Eq. (3) and Figure 5. This composite mapping is also called bilinear
transformation.

)
[

]
(3)

Figure 5: The result of composite mapping of

3. The Boolean summation


The final step to obtain TFI transformation is by applying Boolean summation on and
. Ordinary sum of and will create the correct shape of physical domain but with two sets
of points coincide with each other in the quadrilateral ABCD region (region with straight lines
connecting vertices A, B, C, and D). Thus we need to subtract one set of points within this
region so that it remains only the other set. This can be done by subtracting (
the ordinary sum of
and
which operation is called Boolean summation of
(designated as
). The final TFI is shown in Eq. (4).

) from
and

(4)

2. Grid Generation of air around the Air Foil


In generating grid for the air foil, we will use the TFI transformation which has been
explained in the previous section. In order to generate the grid, the physical domain will be cut
starting at the trailing edge right to the circular outer boundary so that the physical domain as if
has four sides, i.e., AB (left), CD (right), AC (bottom), and BD (top) as seen in Figure 6. However,
we must keep in mind that line AC and BD actually coincide with each other. The TFI code is
written in MATLAB in conjunction with the given Karman-Treffetz airfoil code which is also
written in MATLAB. They will be presented at the end of this report.

Figure 6: The cut-physical-domain having four hypothetical sides AB, CD, AC, and BD

Two types of grid are generated, i.e., one with uniform spacing and one with spacing
that is smaller at one face and gradually increases as it approaches the other face. In other
words, there is higher number of grids where the grid spacing is small and it gradually becomes
less as the grid spacing increases. This is done via a stretching function.
In this project, for the uniform grid generation, the computational domain
is a
unit-square uniform grid and then transformed by means of TFI to generate the uniform
grid. However, for the non-uniform grid mentioned above, additional coordinate system
is used as the computational domain that has unit-square uniform grid. Then, via the stretching
function it is transformed to
coordinate system to become a unit-square non-uniform
(clustered) grid. This finally will be transformed to
coordinate system as non-uniform
(clustered) grid in the physical domain.
Figure 7 and Figure 8 show normalized uniform grid with number of grids of 21 X 51 and
21 X 21. It can be seen that the larger the number of grids, the smoother the geometry will be.

Figure 7: Normalized uniform grid 21x51

Figure 8: Normalized uniform grid 21x21

Figure 9(a) and (b) show the normalized clustered grid with number of grids of 21x51
and stretching parameter, , of 1.01. Figure 10 shows a normalized clustered grid with the
same number of grids as that in Figure 9, but with
. Comparing Figure 9 and Figure 10,
one can notice that the latter does not show any clustering. This is because high will make the
slope of the stretching function ( ) approaches constant. In order to have clustered grid the
slope,

, must be small to get high density grid and large to get low density grid. This trend can

be seen clearly in Figure 11 and Figure 12.

(a) Full view

(b) Close up view near the air foil


Figure 9: Normalized clustered grid 21x51 with stretching parameter,

Figure 10: Normalized clustered grid 21x51 with stretching parameter,


obvious due to high value of

. The clustering is not

0.8

x coord

0.6

0.4

0.2

0
0

0.2

0.4

0.6

0.8

z coord
Figure 11: Plot of vs at
. The slope is small near the air foil surface ( value close to zero)
and becomes larger as it approaches the air outer boundary

x coord

0.8

0.6

0.4

0.2

0
0

0.2

0.4

0.6

0.8

z coord
Figure 12: Plot of vs at

. The slope is nearly constant which explains why at this value of , the
grid clustering is not obvious

APPENDIX A : Matlab code for TFI


% NI,NJ are the number of points in the ki and eta direction, respectively
NI=21; NJ=21;
ki=zeros(NJ,NI); eta=ki;
x=zeros(NJ,NI); y=x;
zeta_coord = 0:1/(NI-1):1;
eta_coord = 0:1/(NJ-1):1;
% Uncomment this line to get uniform grid in the ki direction
%ki_coord=0:1/(NI-1):1;
% Stretching parameter Beta where beta > 1
beta=5; alpha=log((beta+1)/(beta-1));
% Uncomment this line to get stretched grid
ki_coord=1+beta*(1-exp(alpha*(1-zeta_coord)))./(1+exp(alpha*(1-zeta_coord)));
% Generating uniform grid in the computational domain ki-eta
[ki,eta]=meshgrid(ki_coord,eta_coord);
close all;
% Defining Domain boundaries

% Lower Boundary
xLower=ki(1,:);
yLower=0*ki(1,:);
% Upper boundary
xUpper=xLower;
yUpper=0*ki(1,:);
% Left Boundary
[xLeft,yLeft]=Karman_Treffetz_Airfoil(NJ) %given in appendix B
chord = (max(xLeft)-min(xLeft))
% Right Boundary
xRight=4*chord*cos(2*pi*eta(:,1));
yRight=4*chord*sin(2*pi*eta(:,1));

% Generating interior points using TFI


for j=1:NJ
for i=1:NI
x(j,i)=(1-ki(j,i))*xLeft(j)+ki(j,i)*xRight(j)+(1eta(j,i))*xLower(i)+eta(j,i)*xUpper(i);
x(j,i)=x(j,i)-(1-ki(j,i))*(1-eta(j,i))*xLower(1)-(1ki(j,i))*eta(j,i)*xUpper(1)-(1-eta(j,i))*ki(j,i)*xLower(end)ki(j,i)*eta(j,i)*xUpper(end);
y(j,i)=(1-ki(j,i))*yLeft(j)+ki(j,i)*yRight(j)+(1eta(j,i))*yLower(i)+eta(j,i)*yUpper(i);
y(j,i)=y(j,i)-(1-ki(j,i))*(1-eta(j,i))*yLower(1)-(1ki(j,i))*eta(j,i)*yUpper(1)-(1-eta(j,i))*ki(j,i)*yLower(end)ki(j,i)*eta(j,i)*yUpper(end);
end
end
% normalizing the grid
x=x./(4*chord); y=y./(4*chord);
% Plotting the final grid
plot(x,y,'k-',x',y','k-')
axis('square')
xlabel('x');ylabel('y')

APPENDIX B : Matlab code for Karman Treffetz Airfoil


function [x,y]=Karman_Treffetz_Airfoil(N)
a=1.09; n=1.94; mux=-0.08; muy=0.08;
theta=0:2*pi/(N-1):2*pi;
zeta=a*exp(i*theta)+mux+i*muy;
z=n*((1+1./zeta).^n+(1-1./zeta).^n)./((1+1./zeta).^n-(1-1./zeta).^n);
x=real(z); y=imag(z);