Advanced CFD Project 1

Embed Size (px)

Citation preview

  • 8/10/2019 Advanced CFD Project 1

    1/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

  • 8/10/2019 Advanced CFD Project 1

    2/14

    Advanced Computational Fluid Dynamics ME687

    Mini-Project 1First 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 innerboundary which is a Karman-Treffetz airfoil.

    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 tangentialdirections, respectively.

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

    Figure 1: Physical Domain

  • 8/10/2019 Advanced CFD Project 1

    3/14

    Solution:

    1.Brief Introduction to TFI Transformation

    Before the code is presented, some concepts will be presented regarding the TransfiniteInterpolation (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

  • 8/10/2019 Advanced CFD Project 1

    4/14

    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 thecomputational 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 inFigure 3.

    Figure 3: The physical domain obtained by transformation

    Secondly, let us again consider another transformation, , which also maps points fromthe 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 curved-

    boundary for AC and BD, while give incorrect straight line for boundaries AB and CD

    (seeFigure 4).

  • 8/10/2019 Advanced CFD Project 1

    5/14

    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 bothtransformations (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 ofthe actual curved-boundaries. The composite mapping function and the resulting physical

    domain can be seen below (Eq.(3) andFigure 5.This composite mapping is also called bilinear

    transformation.

    ( ) [ ] [ ]

    (3)

  • 8/10/2019 Advanced CFD Project 1

    6/14

    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 setsof 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 ( )fromthe ordinary sum of and which operation is called Boolean summation of and (designated as ). The final TFI is shown in Eq.(4).

    ( )

    (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 beenexplained 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 inFigure 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.

  • 8/10/2019 Advanced CFD Project 1

    7/14

    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 aunit-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 andFigure 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.

  • 8/10/2019 Advanced CFD Project 1

    8/14

    Figure 7: Normalized uniform grid 21x51

    Figure 8: Normalized uniform grid 21x21

  • 8/10/2019 Advanced CFD Project 1

    9/14

    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 thesame number of grids as that in Figure 9,but with . ComparingFigure 9 andFigure 10,one can notice that the latter does not show any clustering. This is because high will make theslope 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 inFigure 11andFigure 12.

  • 8/10/2019 Advanced CFD Project 1

    10/14

    (a)

    Full view

    (b)

    Close up view near the air foil

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

  • 8/10/2019 Advanced CFD Project 1

    11/14

    Figure 10: Normalized clustered grid 21x51 with stretching parameter, . The clustering is notobvious due to high value of

    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

    0 0.2 0.4 0.6 0.8 1

    0

    0.2

    0.4

    0.6

    0.8

    1

    coord

    coord

  • 8/10/2019 Advanced CFD Project 1

    12/14

    Figure 12: Plot of vs at . The slope is nearly constant which explains why at this value of, thegrid clustering is not obvious

    APPENDIX A : Matlab code for TFI

    % NI,NJ are the number of points in the ki and eta direction, respectivelyNI=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 > 1beta=5; alpha=log((beta+1)/(beta-1));

    % Uncomment this line to get stretched gridki_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

    0 0.2 0.4 0.6 0.8 1

    0

    0.2

    0.4

    0.6

    0.8

    1

    coord

    coord

  • 8/10/2019 Advanced CFD Project 1

    13/14

  • 8/10/2019 Advanced CFD Project 1

    14/14

    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);