An Introduction to Computational Fluid Dynamics

An Introduction to Computational Fluid Dynamics

A Workshop hosted at: Department of Mathematics and Computer Science The University of the West Indies St. Augustine, Trinidad. April 22-25, 2003 Invited Speaker: Sergio Rojas, Ph.D. Email: sergio@cecalc.ula.ve http://www.cecalc.ula.ve/ sergio/
 

1

Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

An Introduction to Computational Fluid Dynamics

Outline
1 Incompressible Fluid Flow Equations 1.1 1.2 1.3 1.4 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . Unsteady Navier-Stokes equations . . . . . . . . . . . . . . Steady Navier-Stokes equations . . . . . . . . . . . . . . . Navier-Stokes equations in dimensionless form . . . . . . . 1.4.1 1.4.2 Low High fluid flow . . . . . . . . . . . . . . . . . . fluid flow . . . . . . . . . . . . . . . . . .
¡   ¡  

6 6 8 8 9 9 10 11 11 14

2 On Computational Fluid Dynamics (CFD) 2.1 2.2
2

Why CFD? . . . . . . . . . . . . . . . . . . . . . . . . . . Importance of CFD . . . . . . . . . . . . . . . . . . . . . .
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

An Introduction to Computational Fluid Dynamics

2.3

Steps of a CFD simulation . . . . . . . . . . . . . . . . . . 2.3.1 2.3.2 2.3.3 2.3.4 Pre-Processing . . . . . . . . . . . . . . . . . . . . Processing . . . . . . . . . . . . . . . . . . . . . . Post-Processing . . . . . . . . . . . . . . . . . . . . Problems of a CFD simulation . . . . . . . . . . . . Online CFD sample results . . . . . . . . . . . . .

16 16 17 18 18 19 24 26 30 30 40

2.4

Some CFD sample results . . . . . . . . . . . . . . . . . . . 2.4.1

3 Some aspects of numerical computations 4 Finite Difference Approximation of Differential Equations 4.1 4.2
3

Example: a one dimensional problem . . . . . . . . . . . . A solved example . . . . . . . . . . . . . . . . . . . . . . .
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

.3 5.1 5. . Choosing approximating functions for the unknown 5. . . . . . .2. .3. . . Putting all together . . . . . . . . . . . . . . .2. . . . . . .3. . . . .4 4 One dimensional lineal elements . One dimensional higher order elements . . . .3.3. 5.3 Example: a two dimensional problem .cecalc. . . Choice of the weight function . .An Introduction to Computational Fluid Dynamics 4. .3. 58 64 64 66 68 69 71 72 77 82 82 83 5 Finite Element Method (FEM) 5. . . . .3 5.1 5. . . . . . . . . . Generalities . . . . . .3 Intuitive introduction: the area of a circle . . . .2 Formulating the weak form of the problem . . . . . One dimensional quadratic elements .2. . . . .ula. . .2 5. Sergio Rojas: http://www.2 5. . . . . .1 5. . . . . . Steps of the FEM: a one dimensional model problem . .ve/ sergio/ ¡   .3. . . . . . . .

. . .cecalc. .1 On fluid flow equations expressed in generalized coordinates 126 129 7 Closure 7. .ula. 130 132 References 5 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics 5.5 One dimensional illustrative example (using Mathematica) . . . .ve/ sergio/ ¡ . . . . 94 114 6 Some aspects of grid generation 6. . . .1 On-line general references . . . .

1 Incompressible Fluid Flow Equations Introduction Waves follow our boat as we meander across the lake.ula. Taken from the Clay Mathematics Institute (http://www.claymath.cecalc. Mathematicians and physicists believe that an explanation for and the prediction of both the breeze and the turbulence can be found through an understanding of solutions to the Navier-Stokes equations. and turbulent air currents follow our flight in a modern jet. Although these equations were written down in the 19th Century.org/) 6 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics 1 1. our understanding of them remains minimal.ve/ sergio/ ¡ . The challenge is to make substantial progress toward a mathematical theory which will unlock the secrets hidden in the Navier-Stokes equations.

however.ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics A main characteristic that differentiate a fluid from a solid in that the former can not withstand any attempt to change its shape when at rest. density. and. vary continuously. fluids at rest can not sustain a shear force. If the fluid is in motion. Chouduri 1998). Nevertheless. 7 Sergio Rojas: http://www. The later approach is a necessary step to put on better grounds the results obtained under the assumptions of the continuum hypothesis. derivations of similar equations based on more fundamental ideas coming from physics can also be obtained (Huan 1987.ula. more importantly. Based on the continuum hypothesis which considers that the physical properties characterizing the state of a fluid such as pressure. Sherman 1990). etc. but it can also transmit such force. velocity. That is. it can not only sustain a shear force. it is the road to be follow in situations where the continuum hypothesis assumptions can not be fulfilled.cecalc. as for example for flows at very low density. equations describing the motion of fluids can be derived without regarding the behavior of individual molecules (Batchelor 1987.

ula.An Introduction to Computational Fluid Dynamics 1.cecalc.2 Unsteady Navier-Stokes equations ¢ ¤ £ ¥ ¡  ¤  ¤  ¤  ¤  ¤©£ ¨ ¤ £ ¤©£    § §   ¤ ¦¡ ¢ ¢  ¡   ¤  §    ¤ ¦ ¦¡ ¤  ¨ ¤  ¤¥£  ¤ £ ¥     §   ¢ ¢ ¢ (1)   1.3 Steady Navier-Stokes equations ¢  ¤  ¤  ¤  ¤  ¤ £¨ ¤  ¥ ¤ £ ¥ ¤ £   ¢ ¢ (2)  §     ¢ ¤ £ ¥      ¨ 8 Sergio Rojas: http://www.ve/ sergio/ ¡ .

ula.cecalc. the Reynolds number that is used to characterize the flow regimes (Bachelor 1967.4 Navier-Stokes equations in dimensionless form When dealing with the numerical solution of equations 1. Tritton 1992): £¢ ¤   ¨ ¡  ¡    1. including a dimensionless parameter.4. both .1 Low fluid flow ¢ £ ¢ ¡   ¥ ¡ ¢ £ ¨ ¢ ¢ £ ¢ ¢ ¢ £  ¢ ¨ ¡    § ¦¡ ¡ ¦¡      ¥   ¥ (3) §  ¥¨ ¥¨ ¨ ¢ £ ¢     §  ¨   ¨    ¥¨    9 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics 1. two dimensionless form are commonly encounter in the literature.ve/ sergio/ ¡ .

ula. to be one of the seven greatest open problems in mathematics at the Clay Mathematics Institute of Cambridge. Finally. Massachusetts (http://www. 10 Sergio Rojas: http://www.4.claymath. let’s mention that a complete description of a fluid flow problem could involve the coupling with other equations like energy conservation (i.org/Millennium Prize Problems/).An Introduction to Computational Fluid Dynamics 1.cecalc.2 High fluid flow ¢   As a way of referring to the challenge and difficulties that the question of global existence and uniqueness of the solution of the Navier Stokes still represent.ve/ sergio/ ¡ ¡   ¢ £ ¥¨  § ¡ ¦¡ ¡ ¢ £ ¨ ¢    §    ¨  ¨   ¢ £ ¢ ¢ ¢ £  ¢ ¥   ¥ (4) ¥ ¥¨ ¨  ¦¡   ¡ ¢ £ ¢     §   ¥¨    ¨ . in year 2000. let me just mention that this problem was declared. heat transfer) or auxiliary (phenomenological or constitutive) equations describing the physics of the flow phenomenon under consideration.e.

An Introduction to Computational Fluid Dynamics 2 2. much of the numerical methods applied today were developed during the 1970’s and 1980’s and the development is still going on. however.1   On Computational Fluid Dynamics (CFD) Why CFD? As was stated in the previous section. That is. especially in the physical parametrization of the flow models.cecalc. So. that a good high quality CFD code is necessary to get a feeling of what this field is all about. one way of progress in the field is resorting to the use of numerical methods. In so.ve/ sergio/ ¡ . CFD is basically a relative new field of science that includes all the steps involved in simulating a fluid flow on the computer .ula. One should mention. the complexity of finding solutions of Navier Stokes equations is so great that such a problem has been put in the list of the greatest unsolved problems. and without real 11 Sergio Rojas: http://www.

An Introduction to Computational Fluid Dynamics

experiments CFD results are doubtful in the sense that one can not be certain weather one is looking at an answer that the mother nature likes and can reproduce. An schematic representation of a CFD problem formulation can be found at http://www.metacomptech.com/cfd++/physics domain.html:
 

12

Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

An Introduction to Computational Fluid Dynamics

13

Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

An Introduction to Computational Fluid Dynamics

2.2
     

Importance of CFD
Let’s first mention that the investment cost of having a high quality CFD capability are not small, but the total expense is not as great as that of a high quality experimental facility. Current computer technology progress may drop the cost dramatically. CFD is of fundamental importance in the predicting of flow behavior for full scale of number. The nonlinearity of the Navier Stokes equations is the main responsible for the variety of solutions that have been found as , being turbulence one of the most fascinating and intrigued phenomena that still defy explanation.
¡  

CFD plays important role in the airplane industry, where planes are designed based on numerical computations of a flow passing any part of the airplane. Other applications involves the ship industry, oil industry, medicine, etc. Moreover, numerical experiments are helping
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

¡  

 

¡

14

To write good quality CFD code will take some time and a lot of intellectual resources.e.cecalc.ve/ sergio/ ¡       15 . The results obtained from a CFD simulation can be used to analyze existing designs (. even when one plans Sergio Rojas: http://www. it is worthwhile to spend some time on understanding the main aspects of CFD.ula. The ability to simulate ideal conditions is important for understanding the theory behind the model being described.i.An Introduction to Computational Fluid Dynamics to understand behavior of various type of flows that can be used to comprehend open theoretical questions related to the existence and uniqueness of a solution of the equations describing the motion of fluids. airplanes or automobile shapes) and propose the creation new ones: optimize processes and products. to understand the physics of the phenomena under study and propose new experiments that could help to comprehend features not seen in regular experiments. Nevertheless.

ula. finite elements.1 Pre-Processing Basically.3 Steps of a CFD simulation Once the mathematical model is obtained and the equations discretized according to the numerical methodology (finite difference.An Introduction to Computational Fluid Dynamics to use somebody else code to perform our own research or to develop a better understanding on the phenomena of fluid flow. 2.cecalc. FEATFLOW. usually a CFD simulation involves three basic step: 2. etc. etc).) and coded in a computer program (i.e. in this step the performer of a CFD simulation set up the physical parameters defining the fluid(s) and material(s) properties 16 Sergio Rojas: http://www. FIDAP.3. FLUENT.ve/ sergio/ ¡ . finite volume. CFDRC. Being familiar with the principles of CFD will allow us to comprehend much better the computational results obtained through numerical simulation.

An important and perhaps the most labor intensive part of the model is the design and generation of the grid or mesh where the computations will be carried out.2 Processing At this level of the CFD simulation.cecalc. boundary conditions set up) related to the problem at hand and link them with the computational engine (solver) that will actually solve the set of discretized equations. 2.3.An Introduction to Computational Fluid Dynamics involved in the simulation to be carried out. the quality of the computational grid and the mathematical model of the physical phenomena being modeled will affect how closely the computer solution can approach reality. Essentially.ula.e.ve/ sergio/ ¡ . 17 Sergio Rojas: http://www. the user usually can write custom User Defined Functions and Subroutines to incorporate special functionality (.i.

Problems with multiple solutions (non-linearities are present) are hard to deal with.ula.3 Post-Processing In the steps the analysis of the obtained numerical results is carried out.An Introduction to Computational Fluid Dynamics 2. Sergio Rojas: http://www. may be very expensive. The results are often presented graphically to assist in visualizing what’s happening in the flow domain. and the user decide whether a new execution of the simulation is required. Let’s just mention a few problems that one could face whenever doing CFD: Numerical solution may experience instabilities and divergence.3.cecalc. if possible.4 Problems of a CFD simulation Computer simulations are far from being the panacea of all our computational problems. Solution.3. 2.ve/ sergio/ ¡     18 .

Research in computational methods are devoted to finding better and reliable ways to diminishing these and other disadvantages of CFD.An Introduction to Computational Fluid Dynamics The mathematical model may not be adequate to properly describe the physical situation being simulated.     19 Sergio Rojas: http://www.ula.cecalc. The other two classical fields are experimental and theoretical fluid dynamics. Real experiments are necessary to fully be confident of the numerical results. the role of CFD has become so strong that it can be considered as a third area of fluid dynamics. Moreover.ve/ sergio/ ¡ .

ula.cecalc.An Introduction to Computational Fluid Dynamics 2.4 Some CFD sample results 20 Sergio Rojas: http://www.ve/ sergio/ ¡ .

cecalc.An Introduction to Computational Fluid Dynamics 21 Sergio Rojas: http://www.ve/ sergio/ ¡ .ula.

cecalc.ve/ sergio/ ¡ .ula.An Introduction to Computational Fluid Dynamics 22 Sergio Rojas: http://www.

An Introduction to Computational Fluid Dynamics 23 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/ ¡ .

ve/ sergio/ ¡ .cecalc.com/movies/ Some FEATFLOW CFD results: http://www.org/phf/gallery/index1.vt.htm               Some of this sites show pictures of real fluid behaviour.rice.An Introduction to Computational Fluid Dynamics 2.eng.htm Other: http://www. Some sites are: From Physics of Fluids Journal: http://ojps.edu/ mech372/album/ Gallery of Fluid Dynamics: http://www.vt.aip. 24 Sergio Rojas: http://www. others are obtained via CFD simulations.de/album/ Pictures from the book An Album of Fluid Motion by Milton Van Dyke.1 Online CFD sample results Many other examples can be found on the Internet.itsc.4.edu/fluids/msc/gallery/conden/conden. 1982: http://www.owlnet.eng.featflow.edu/fluids/msc/gallery/gall.jsp From CFD and thermal analysis archive: http://www.ula.

An Introduction to Computational Fluid Dynamics At CeCalCULA (http://www.ula.ve/) we have available FLUENT and CFRC.ve/ sergio/ ¡ . to perform fluid dynamics simulations.cecalc.ula. We are in process of getting involved on a research project to study flow of blood in thin capillaries. two well known CFD software packages. 25 Sergio Rojas: http://www.cecalc.

. mathematical.e. numerical solutions of physical. ) to generalized ( . etc) that do not coincide with coordinate lines in physical space. ) space are introduced such that a PSfrag replacements distorted region in physical space is mapped into a rectangular region in the generalized coordinate space (see figure 3). .ve/ sergio/ ¡ . automobiles. .ula. transformations from physical ( . and engineering problems involves complex shapes as computational boundaries (i. . So. buildings. ¥   ¡ Figure 1: From physical ( .. flowfields computations around aircraft.An Introduction to Computational Fluid Dynamics 3   Some aspects of numerical computations In general. ) space to a generalized curvilinear coordinates ( . ) ¢ ¤ £ ¡ ¤ £   ¥ ¢ ¥   ¡ ¢ ¤ £ 26 Sergio Rojas: http://www.cecalc.

ula. departures from orthogonality of can be tolerated. This.cecalc. up to One should deal with the convergence of a numerical discretization scheme whenever one get concerned with the circumstances under which the numerical solution will coincide with the true solution.An Introduction to Computational Fluid Dynamics Experience and mathematical demonstrations show that to obtain high accuracy in a computed numerical solution the grid should be orthogonal or near orthogonal. however. One criterion is that: ¢£¡       27 Sergio Rojas: http://www.ve/ sergio/ ¡ . Indirectly routes to explore the convergence of a numerical scheme have been devised. the use of generalized coordinates introduces additional terms in the truncation error if the grid is not orthogonal. In fact. implies relatively simple boundary shapes for the computational domain and some restrictions on the disposition of the grid points. Establishing convergence directly is in general a very difficult matter. Nevertheless.

From the truncation errors analysis.ula. It must be stable. That is. becomes smaller ( ¢ ¢          28 Sergio Rojas: http://www.ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics Consistency Stability Convergence ¡ Consistency: implies that the discretization scheme can be reverse to obtain the governing equation(s). stability is the necessary and sufficient condition for convergence. Stability: has to do with the algorithm applied to solve the discretized equations. it is expected to obtain a more accurate solution as the grid size of the computational domain ). Lax Equivalence Theorem (time dependent problems): Given a properly posed linear initial value problem and a discretization scheme to it that satisfies the consistency condition.cecalc. errors do not grow as the as the computation of the solution progress.

There are circumstances on which one is only concerned in obtaining a computational solution close to the true solution at some level of accuracy. like for instance the error function).ula. without worrying about the convergence of the approximation scheme (example are some no convergent series that are commonly use to find numerical values of some functions.ve/ sergio/ ¡ .cecalc.An Introduction to Computational Fluid Dynamics To achieve a level of accuracy. sometimes computational efficiency requires to solve a higher-order discretization scheme on a coarse grid than a low-order scheme on a finer grid.     29 Sergio Rojas: http://www.

ula.ve/ sergio/ ¡ ¡   ¢ ¡¢   ¥ £¨  ¥¨ ¥¨   ¨ ¥ ¤¨ ¥ ¦ ¥ ¥ ¥¦ ¥ ¥ § § §¨ ©    ¨  §  ¥ ¨ ¥ ©¨ ¡   ¡¢       ¥ §    § ©  ¨  ¥ §   ¨ .An Introduction to Computational Fluid Dynamics 4 Finite Difference Approximation of Differential Equations Example: a one dimensional problem 4.cecalc.1 We would like to find the numerical solution of: on (5) subject to: (6a) (6b) Finite difference approximations of derivatives are found starting from 30 Sergio Rojas: http://www.

ve/ sergio/ ¡ ¥ §   ¥ ¥  ¥ §  ¥ §  ¨  ¨ ¥    ¨ § © ¥ ¥ ¥   §   .cecalc. and ¥¦ are obtained from . The results   ¥ §¨ © Sergio Rojas: http://www.1: ¥¨  § ¥ §   ¥ ¥¨   §   ¥ ¥   ¨  ¨  ¢ ¢ £  ¡ ¦ ¦ £   ¤ ¤ ¥         ¥ ¥¨ ¥ ¥ ¥   ¨  ¥   can be discretized in a set of points as shown in figure        § ¡ ¨ §  ¨    ¥¦ ¥ §¨ ©    ¨ § © ¨ ¥ ¥ ¥ ¥ ¥ So.  ¨©§ © around .ula.An Introduction to Computational Fluid Dynamics Taylor expansion of around  :  PSfrag replacements ¥ ¨ ¥     ¥     (7) ¡   ¥¨ ¥   ¥   ¡   ¢  ¨   The interval 4. Taylor expansion of equation 7 by substituting 31  ¥   § §    ¥   § Figure 2: Discretization of the interval and .

ula.(8)    ¡   ¥ § ¡ ¦ £ ¦ £ ¡ ¥ ¨  ¤ §     § § § ¨   ¥ ¡   ¥ § ¥ ¨  ¤ §  § ¡ ¡ ¨ § § ¥¨ §   §  ¥ §  ¥¨  § ¥  ¨©§ ¡   An Introduction to Computational Fluid Dynamics  ¥ ¨  ¨ § §   § § ¨ ¥ § ¤ ¥ ¢ £ ¡   ¢  ¥ ¨  ¥¨ ¥¨ §  ¥¨ § ¢    ¥ § ¥ §  ¤  §  ¥  ¨ § © ¢ £   ¥¨ ¢ § ¥ §     §  ¨  ¥¨ §  ¥¨ §  ¥ §   ¥ §  ¥  §   ¨  ¨ § ¨©§ ¥¨ § are:   ¥¨   32 Sergio Rojas: http://www.cecalc.ve/ sergio/ ¡  ¦   ¥  ¦       (9)     § ¥¨   .

ula.(10)     § § adding and subtracting equations 8 and 9 one obtains: ¡¢   © ¨ § ¨ § © ¥¨ ¢ §  ¡ ¡  ¢ £ ¦ £  ¥  ¡ ¥  ¥ § ¢  ¡ ¡ ¡ ¦  ¨ § ©  © ¨ § An Introduction to Computational Fluid Dynamics  ¥  §  ¥¨ § § ¥ § ¥¨ § ¨ § ¥¨ §  ¥ § ¡ ¨©§  ¥¨    ¥¨ ¥ ¡  ¥  ¨ § © ¥¨ § ¥  ¥ ¥¨ § ¡    § § ¥ § §  ¢  © ¨ §    ¥¨ §   ¥    ¥¨ §    ¨    ¥ §  ¢  ¨   § ¥  § ¨ § ©  §   ¥ §  ¦  ¥ ¥¨    ¥ §  ¥¨ §     §  ¥¨   ¥¨ §    §  § ¨ § §   ¥¨ §    33 Sergio Rojas: http://www.cecalc.ve/ sergio/ ¡ ¡     ¢ £ ¥ ¨ ¤ ¥¨   ¨ § § ¡         § § § ¥¨ §  ¥ §    ¨ ¥ ¡        ¥ ¨ ¤ ¤ ¥ ¨  (11) ¥¨  §    .

An Introduction to Computational Fluid Dynamics in the case of having a uniform grid.ula. ¡   34  ¢ £ ¤     ¥¨  ¡ ¢ ¥ § §   ¨  ¥ (12a)  ¨©§  ¨ § ¥¨ § ¥  ¡ ¢       ¨  ¡  ¥ § ¥ ¥ ¢   § §  ¨  §  ¨  ¨  ¡¢   ¦ £ ¤     ¥¨     ¢ ¥¨ § §   ¡  (12b)  ¨ § © ¡ ¥¨ § ¥ § ¥   §      ¨   ¢  ¨ Sergio Rojas: http://www.cecalc. equations 10 and 11 yields what is called centered finite difference discretization schemes for first and second order derivatives and having a second order truncation error:     © ¨ § ¢ ¥¨ § ¥ § ¥ ¥   §   ¨   ¨ § © ¥ ¥ ¢   §  ¨  §  ¨ Substitution of approximations 12a and 12b in our differential equation 5.ve/ sergio/ ¡  . .

ve/ sergio/ ¡  §    § § § § ¨        £ §     £ §  ¡ ¢ ¢ ¡   ¤ ¤ § § §  ¢   £ §  ¥ § §  ¡ ¢ ¢   ¦ § § . and evaluating each term at  ¨ § ¡ one obtains:  ¨ §  ¥ § ¥ ¥ ¥ which can be rewritten in the form: (13a) (13b) (13c) (13d) (13e)   £ ¥ § ¥¨ ¥¨     § § §  ¨  ¨  ¨ 35   ¢      £¨ ¥ § §   ¡ ¢    ¢  ¤¨ ¥ § § § §   ¥ ¦ ¥¨  ¡ ¨   ¨  ¨ § § ¤ ¡ ¥    ¢ § § Sergio Rojas: http://www.ula.An Introduction to Computational Fluid Dynamics on page 30.cecalc.

and .ve/ sergio/ ¡ .ula. which can be eliminated by use of the extra unknowns. and boundaries conditions (equations 6a and 6b on page 30) discretized with the and finite difference approximation 12a. . Noting that correspond to nodes at which and respectively. the substitution of equation 12a on the boundary conditions. Inspection of this equation shows that its evaluation at nodes and introduces two . and taking the first ) and last ( ) equations from equation 13 one obtains: (   § ¡ £ ¤ ¦ ¥¨ § § § §          ¢ ¡ ¡           ¥ ¥ ¥ ¥ § ©     ¢ ¡ ¡     ¢ ¡ ¡ (14a) (14b) (14c) (14d)     ¡ ¢ ¤      §  £  ¥      § §                   §         ¡ ¢  ¨ £ ¥ ¤  § §              36 Sergio Rojas: http://www. equations 6.cecalc.An Introduction to Computational Fluid Dynamics where and similarly with .

An Introduction to Computational Fluid Dynamics

After combining this equations one finally gets the full centered finite difference discretization of equation 5 subject to the boundary conditions given by equations 6a and 6b:

(15a) (15b) 

   

¤ ¥ £ £ £   

§

§

§

§ 

¨
  ¡ 

¡
¢ 

¡
¢ ¢ 

  

¡ 

     

  

¨ § ©

£

¤ ¡ ¥ 

¡

¢

 

§

§ 

§ § § § §
  

§

¨¨

  

 

  

are given by equations 13b-13e. The set of where , , , and that can solved numerically using equations 15 are of the form readily available algorithms in many Numerical Analysis texts. If computer efficiency is an issue, one will need to use sophisticated algorithms that make use of the structure of the matrix to find the numerical solution of
£ ¤ 

  
  
¨
£ ¥ ¥ ¥ ¤ 

 

§

§

§ 


¨ 

(15c)
  ¡

     

  

    

¡
¢ ¢ ¢

¡

¡ 

¥

§

§

§

§ 

¤

¢

¥

£

37

Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

An Introduction to Computational Fluid Dynamics

such algebraic system of equation very efficiently not only in terms of computer time but also in terms of minimizing the intrinsic computational errors. In the case of the example we are looking at, it happens that matrix the banded tridiagonal form:
¡ ¢

is of

¢     

  £ ¡ ¢ ¦  

 
  ¦ 

    ¦ ¦  

(16)

£

¡

¢ 

¢ ¢ ¢
  ¦   

efficient mathematical algorithms have been devised to find numerical solutions of systems of equations leading to tridiagonal matrices. In
38 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

¢     £ ¡ ¢ ¦ ¦ 

¦ ¦ ¦
      £ ¡ ¢ ¦ ¦ ¦ 


¤ ¤ ¤   £ ¡ ¦  


¥ ¥ 

  

An Introduction to Computational Fluid Dynamics

particular, most of them make use of the storage of a matrix such as of equation 16 in what is called tridiagonal storage mode, which means storing the elements of the tridiagonal matrix in three one-dimensional arrays each of length n (the order of the matrix) stored as follows:
¢

sub-diagonal elements diagonal elements super-diagonal elements

¢

(17a) (17b) (17c) (17d) 

¡ ¨ ¢   

   
¤

¡
£ £ £ £

 
£

¡

¨ 

 

¨
¡

¨
 

¨

where ”*” means an arbitrary not used element. (in our center CeCalCULA (http://www.cecalc.ula.ve/) we have available the UCSparseLib library (developed for one of ours collaborator), the commercial Mathematical and Statistical Library IMSL and the IBM Engineering and Scientific Subroutine LIbrary (ESSL and PESSL) to perform numerical computations,
39 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

¡

¡

¡

¡

¡

£

¡

¨
¨
¡
 

¨ 

¡

¨
 
¢ ¢ ¢ ¢

¨
£

¨
¨ 

¨

¨

¨

ula.cecalc.2 A solved example Let’s apply the theoretical ideas presented in the previous section to find the numerical solution of (compare with equation 5.An Introduction to Computational Fluid Dynamics including the use of parallel (hight performance) computations. 4.ve/ sergio/ ¡ . on page 30): on     ¥  ¨ ¥    ¡ ¢   ¥ ¨  ¥ ¨ ¥  ¥ ¨ ¦     ¥   with: ¦ (18a)  ¦ ¡  ¡   ¥¨   ¢ ¥ § ¢      ¨© ¡ ¥¨  ¤ £ ¥ § § ¨   ¡ ¥¦§ ¤ ¥  ¨  ¤ ¥ § ¤ ¥ 40 Sergio Rojas: http://www.

based on the ideas presented in the previous section. For illustrative purposes it makes use of a subroutine that was written to find numerical solutions of systems of equations leading to banded tridiagonal matrices (the tridiagonal solver can be found in reference [6]).An Introduction to Computational Fluid Dynamics subject to bc’s 6. #--------# Makefile #--------COMPILER = pgf90 41 Sergio Rojas: http://www.cecalc. page 30. is given below.ve/ sergio/ ¡        ¤         ¡ ¤  ¥ § ¤  ¥  ¨  ¨  .ula. where: (18b)        ¡  The exact solution is given by: (18c)  ¨© The listing of a Fortran code implementing the solution of this problem.

o \ tridag.o \ Func_Coef_S.o: main.f90 \ myFunc/First_Der_Coef_R.f OBJECTS = main.ula.f90 42 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics SOURCE_FILES = main. #---exec_file: $(OBJECTS) $(COMPILER) $(FLAGS) $(OBJECTS) -o exec_file $(LIBS) main.f90 \ myFunc/Eq_rhs_T.f90 \ NR/tridag.f90 \ myFunc/matrix_A.o \ Eq_rhs_T.f90 \ myFunc/Func_Coef_S.o LIBS= FLAGS = #---# NOTE: you must make the white space just before the $(COMPILER) # instruction by hitting the computer TAB keyword.o \ First_Der_Coef_R.o \ matrix_A.cecalc.ve/ sergio/ ¡ .

f90 $(LIBS) matrix_A.out mrun: exec_file !-------- 43 Sergio Rojas: http://www.o: myFunc/First_Der_Coef_R.cecalc.f $(LIBS) mclean: rm -rf $(OBJECTS) file.ula.An Introduction to Computational Fluid Dynamics $(COMPILER) $(FLAGS) -c main.o: myFunc/Eq_rhs_T.f90 $(LIBS) Eq_rhs_T.o: myFunc/matrix_A.f90 $(LIBS) tridag.f90 $(COMPILER) $(FLAGS) -c myFunc/Eq_rhs_T.f90 $(LIBS) First_Der_Coef_R.ve/ sergio/ ¡ .f90 $(COMPILER) $(FLAGS) -c myFunc/First_Der_Coef_R.o: myFunc/Func_Coef_S.f $(COMPILER) $(FLAGS) -c NR/tridag.f90 $(LIBS) Func_Coef_S.f90 $(COMPILER) $(FLAGS) -c myFunc/Func_Coef_S.o: NR/tridag.f90 $(COMPILER) $(FLAGS) -c myFunc/matrix_A.

:) DOUBLE PRECISION. RHS(:). ALLOCATABLE :: AA(:. H CHARACTER*20 FNAME DOUBLE PRECISION :: PI PI = 4. ALLOCATABLE :: A(:). copyRHS(:) DOUBLE PRECISION. C(:). copyC(:). alpha2. beta1. alpha1. gamma2 DOUBLE PRECISION :: K. gamma1. U(:) DOUBLE PRECISION. Sol.N).A)’.0D0) write(*.An Introduction to Computational Fluid Dynamics !main. j DOUBLE PRECISION. B(:).f90 !-------PROGRAM FINITE_DIFFERENCE_1D IMPLICIT NONE INTEGER N. beta2. ALLOCATABLE :: copyAA(:. ’(5X. Xb. STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " 44 Sergio Rojas: http://www.0D0 * ATAN(1.ve/ sergio/ ¡ . i.cecalc. copyR(:) DOUBLE PRECISION :: Xa. X.ula.*) N ALLOCATE (AA(N.:). ALLOCATABLE :: copyA(:). AllocateStatus. copyB(:). ADVANCE=’NO’) ’How many nodes?: ’ READ (*.

0D0 xb = -1. and gamma2: ’ ! READ (*.A)’. beta2.ADVANCE=’NO’) ’Enter alpha2.ADVANCE=’NO’) ’Enter left(Xa) and right(Xb) boundaries: ’ READ (*. Xb ) write(*.copyC(N).B(N).’(5X. beta1.’(5X.N).’(5X. beta2. beta1. and gamma1: ’ ! READ (*.*) alpha2.U(N).0D0 DO WHILE( Xa .A)’.ula.An Introduction to Computational Fluid Dynamics ALLOCATE (copyAA(N. gamma1 ! write(*. gamma2 !----- 45 Sergio Rojas: http://www.A)’.C(N).GE. STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " ALLOCATE (A(N).RHS(N).ADVANCE=’NO’) ’Enter alpha1.copyRHS(N). STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " ALLOCATE (copyA(N).copyR(N).ve/ sergio/ ¡ .copyB(N).cecalc.*) Xa. STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " Xa = 0. Xb END DO !----! write(*.*) alpha1.

0d0 4.A.beta2.gamma1.1:n) copyA(1:n)=A(1:n) copyB(1:n)=B(1:n) copyC(1:n)=C(1:n) copyRHS(1:n)=RHS(1:n) ! DO i=1.B.20) (AA(i.C.Xb.0d0 -2.K(Xa) 1.N 46 Sergio Rojas: http://www.N) ! end do ! DO i=1.An Introduction to Computational Fluid Dynamics alpha1 beta1 gamma1 alpha2 beta2 gamma2 = = = = = = .0d0*PI CALL get_matrix_A(AA.alpha1. & alpha2.RHS.gamma2) !saving a copy of A copyAA(1:n.N ! write (*.ve/ sergio/ ¡ .j). j=1.ula.beta1.cecalc.0d0*PI K(Xb) 1.N.Xa.1:n)=AA(1:n.

C.ve/ sergio/ ¡ .22) (U(i) .B.23) x.’abs(diff)’) 19 format(’#’.6) 47 Sergio Rojas: http://www.Sol(X))/U(i))*100.22) A(i). abs((U(i) .19) h = (Xb-Xa)/(N-1) !DO i=1. Sol(X).RHS.Sol(X))/Sol(X))*100.N) open(10.’------’.ula.’---’.N-1 X = DBLE((i-1))*h + Xa !write (*.11x. U(i).9x.’numSol’.N DO i=2.7x.An Introduction to Computational Fluid Dynamics ! write (*.file="file.4) 22 format(F16.18) write (10. RHS(i) ! end do CALL TRIDAG(A.9x.’---------’) 20 format(6F10.Sol(X)) write (10. C(i).0d0 !write (10.’exactSol’. U(i).’--------’.11x.7x.out") write (10. Sol(X). B(i).8x.8x.cecalc.23) x.U. abs((U(i) .’ x ’.0d0 end do close(10) 18 format(’#’.

’\t\t **** Calling Gnuplot *****’ call system("gnuplot < myplot.6) print *.gnu") DEALLOCATE (A) END PROGRAM FINITE_DIFFERENCE_1D !---------------------------Double Precision FUNCTION SOL(X) IMPLICIT NONE DOUBLE PRECISION X DOUBLE PRECISION PI PI = 4.ula.cecalc.0D0 * ATAN(1.An Introduction to Computational Fluid Dynamics 23 format(4F15.ve/ sergio/ ¡ .0d0*PI*X) return end !---------------------------- 48 Sergio Rojas: http://www.0D0) SOL = SIN(2.

gamma1.f90 !-----------SUBROUTINE GET_MATRIX_A(AA.0D0 * ATAN(1. C.C1.N. gamma1. B. C. gammaN DOUBLE PRECISION :: X.betaN.RHS.gammaN) IMPLICIT NONE INTEGER N.An Introduction to Computational Fluid Dynamics Double Precision FUNCTION K(X) IMPLICIT NONE DOUBLE PRECISION X K = 1. J DOUBLE PRECISION :: AA(N.& alphaN.alpha1.A1. Xb DOUBLE PRECISION :: alpha1. beta1. betaN.ve/ sergio/ ¡ . RHS(N). D double precision pi pi = 4.0D0) 49 Sergio Rojas: http://www.Xa. B1(N).B1.cecalc.Xb.ula. A1(N). C1(N). D external A. A.0d0 + X*X*X*X return end !-----------!matrix_A. I. h2.N). B. Xa.beta1. alphaN. h.

ula.I-1) B1(I) = AA(I.h) AA(1.h) AA(I.2) x = Xa + h DO I = 2.h) + beta1*A(Xa.Xa) /(DBLE(N)-1. N .1) C1(1) = AA(1.0D0*h AA = 0.I+1)=C(X.h)) RHS(1) = (alpha1/h2)*D(Xa) + A(Xa.I)=B(X.0D0) h2 = 2.h) AA(I.An Introduction to Computational Fluid Dynamics h = (Xb .h) RHS(I) = D(X) A1(I) = AA(I.2) = (alpha1/h2)*(A(Xa.ve/ sergio/ ¡ .0d0 B1(1) = AA(1.h) + C(Xa.I+1) x = x + h 50 Sergio Rojas: http://www.0D0 AA(1.h)*gamma1 A1(1) = 0.1 AA(I.1) = (alpha1/h2)*B(Xa.I-1)= A(X.I) C1(I) = AA(I.cecalc.

0d0 END SUBROUTINE GET_MATRIX_A Double Precision FUNCTION A(X.N)= (alphaN/h2)*B(Xb.An Introduction to Computational Fluid Dynamics END DO AA(N.h)) AA(N.d0*h) return end Double Precision FUNCTION B(X.h) 51 Sergio Rojas: http://www. N .1) B1(N) = AA(N. h.1)= (alphaN/h2)*(A(Xb.h) RHS(N)= (alphaN/h2)*D(Xb) .ve/ sergio/ ¡ . R External R A = 1.h) + C(Xb.gammaN*C(Xb.R(X)/(2.h) .ula.h) IMPLICIT NONE DOUBLE PRECISION X.0d0/(h*h) .betaN*C(Xb.h) A1(N) = AA(N.cecalc. N ) C1(N) = 0. N .

h. h. S External S B = -2.ve/ sergio/ ¡ .d0*h) return end Double Precision FUNCTION C(X.h) IMPLICIT NONE DOUBLE PRECISION X.ula.An Introduction to Computational Fluid Dynamics IMPLICIT NONE DOUBLE PRECISION X. T External T 52 Sergio Rojas: http://www.d0*h) return end Double Precision FUNCTION D(X) IMPLICIT NONE DOUBLE PRECISION X. R External R C = 1.cecalc.S(X)/(2.0d0/(h*h) + R(X)/(2.0d0/(h*h) .

0d0*PI*X*X*X*COS(2.0d0*PI*X) 53 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics D = T(X) return end !----------!Eq_rhs_T.0D0 * ATAN(1.f90 !----------! ! u’’ + R(x)*u’ + S(x)*u = T(x) ! ! Right Hand Side of equation.ula.0d0*PI*X) + 4.0d0*PI*PI*B*SIN(2.cecalc. b. ! Double Precision FUNCTION T(X) IMPLICIT NONE DOUBLE PRECISION X DOUBLE PRECISION :: a. PI PI = 4.ve/ sergio/ ¡ .0D0) b = 1.0d0 + X*X*X*X a = -8.

a/b return end !-------------------!First_Der_Coef_R.cecalc.An Introduction to Computational Fluid Dynamics T = .0d0*X*X*X)/(1.ve/ sergio/ ¡ .ula.f90 !-------------------! ! u’’ + R(x)*u’ + S(x)*u = T(x) ! ! Coefficient of first derivative ! Double Precision FUNCTION R(X) IMPLICIT NONE DOUBLE PRECISION X R = (4.0d0 + X*X*X*X) return end !--------------- 54 Sergio Rojas: http://www.

ula. D ! K = 0.f Fronm Numerical Recipes 55 Sergio Rojas: http://www.0d0 ! -K/D.An Introduction to Computational Fluid Dynamics !Func_Coef_S.2d0 ! D = 2. return end c------ctridag.f90 !--------------! ! u’’ + R(x)*u’ + S(x)*u = T(x) ! ! Coefficient of function u ! Double Precision FUNCTION S(X) IMPLICIT NONE DOUBLE PRECISION X DOUBLE PRECISION K.cecalc.0d0 S = 0.ve/ sergio/ ¡ .

-1 U(j) = U(j) .ve/ sergio/ ¡ .A(j)*gam(j) IF (bet.0. NMAx DOUBLE PRECISION A(N). U(N) PARAMETER (NMAx=5000) INTEGER j DOUBLE PRECISION bet. R. N gam(j) = C(j-1)/bet bet = B(j) .) THEN STOP ’tridag failed’ END IF U(j) = (R(j)-A(j)*U(j-1))/bet END DO DO j = N .An Introduction to Computational Fluid Dynamics c-------SUBROUTINE TRIDAG(A. gam(NMAx) IF (B(1). 1. N) IMPLICIT NONE INTEGER N.EQ.ula.1.EQ. U.cecalc. B. C.0.gam(j+1)*U(j+1) END DO 56 Sergio Rojas: http://www. B(N).) THEN STOP ’tridag: rewrite equations’ END IF bet = B(1) U(1) = R(1)/bet DO j = 2. R(N). C(N).

ac. \ "file.html #---# If this does not want to work.out" using 1:2:4 notitle with yerrorbars !echo "waiting 15 seconds to continue" pause 15 57 Sergio Rojas: http://www.out" using 1:3 title "Exact Sol.gnu #----------# # excelent gnuplot site: # http://art." with lines.jp/members/kawano/gnuplot/index-e.ula." with lines.out" using 1:2 title "Numerical Sol.cecalc. take out \ and joint the # lines in one long line #-----------set xlabel "x" set ylabel "y" set title "Finite Difference" plot "file.ve/ sergio/ ¡ .aees. \ "file.An Introduction to Computational Fluid Dynamics RETURN END #----------# myplot.kyushu-u.

An Introduction to Computational Fluid Dynamics 4. The standard classification of such problems as hyperbolic. parabolic or elliptic is less important because the character of £     ¢ £ ¥¨     ¥¨  § ¨    ¨    ¥ ¡   ¡ ¥¨   ¨  ¥¨ ¨  58 Sergio Rojas: http://www.ula.ve/ sergio/ ¡ . These sort of problems are called boundary value (or stationary solution) problems which together with the so called initial value (or time evolution) problems make a most sensed classification of partial differential equations from a computational point of view. being an archetypical example the Poisson equation: (19)   £ £ ¥ ¥¨ ¡ ¡ ¨   ¨   ¨   which satisfy equation 19 Usually one would like to find a function region of interest subject to some desired behavior on within some the boundary of the region of interest (boundary conditions).3 Example: a two dimensional problem A wide variety of physical and engineering problems are posed in terms of second order partial differential equations.cecalc.

change during computation. there may be situations where a problem will remains of a particular type during the whole computation. Nevertheless. one should take advantage of the computational techniques developed for that particular case. Finite difference discretizations have also been developed to find numerical solution of two (and higher) dimensional boundary value problems.ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics them could. by adapting the equations obtained in the one dimensional case to handle the respective higher dimensional case. approximations of relevant derivatives in uniform grids are 59 Sergio Rojas: http://www. as usually happen. In such cases.ula. In the case of of 2D partial differential equations.cecalc.

An Introduction to Computational Fluid Dynamics

written in the form: (20a) (20b) (20c) (20d) (20e)
¨ 

¨ §

£

£

£ ¡

¥ 

§ 

§

¨
  

¨
¡ ¡       


¡

¥
¡
¢

¢ 

¨

£ ¡

¥

£

£  

§

§

§

¨
  

¨
¡ ¡       


¡
¢

¡
  £

being the generalized (also called logical) computational domain a rectangular grid: 


¨ § © ¨ § © ¨ 

£ ¡

¥

£

£

£ §

£        

§

§

§

¨
     

¨
¡ ¡ ¡ ¡           



 

¥
¡
¢   £

¢

¢

¡  
¨ § © ¡

£ ¡ ¡
¢

¥¨
§

£ §

£

£ 

§ § 

¨
   

¡ ¡ ¡           

¥ 

¨ ¡

¢

£ ¡ ¡
  £

¥¨
§

£ §

£

£ 

§ § § 

¨
   

¡ ¡ ¡         

 

¢

60

Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

An Introduction to Computational Fluid Dynamics 

 

. . .

i,j+1 i-1,j i,j i,j-1 i+1,j

Using equations 20, Poisson equation 19 can be written in discretized form
61 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡

         

Figure 3: Example of the discretization of a 2D region

¢  

¥ 
 

¥

¥

¥ 

¢ 

 

¥
§

An Introduction to Computational Fluid Dynamics

as: (21a)
¡    

¨ © ¨ § ¡ ¡

£

£

£

By means of the transformation equation 21 can be rewritten in matrix form: 

¢  

The boundary points, where either
62

£ §

£

£

§ 

§ § 
¡ ¡     

§ 
¡ ¡ ¡ 

§ § 

¡         

¢

§
§ 

¢ ¢ 

(21b) (21c) (see reference [6]), (22a) (22b) (22c) (22d) 
§
£ 

 

  ¡

 

 

¢

¡ 


 

¨
  ¡    
¢

¨ 

£ ¤
¡

¨ ¨
§ ¨ 
¨ ¥

¨ 
 

¨
 
¢

£
¨ ¥

£ § § §

£

£

£

¢ 

¥ 

¥ ¥ 

¥ 
£  ¤

Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
¡   

 £ ¤  

¢  

¤

¡

§
£

§

¨  
  

 

 

 

¢

 

¡

¨ 

 

¨¨
     
¢  

¨
£

or its derivative are specified, are

¨¨ 
£

ve/ sergio/ ¡ .cecalc.An Introduction to Computational Fluid Dynamics defined by: (23a) (23b) (23c) (23d) ¢   ¢       ¡     ¢ ¡   ¤   ¢ ¢   ¨ ¢   ¨ ¢ ¢     ¨       ¢ ¢   ¢ ¡   ¤ § § § § § ¨ ¨  ¨  ¨  ¨ ¨  ¢          ¢ ¢     ¤  § §  ¨ ¨ ¨ £ ¨   ¢   ¢ ¢   ¢    ¡     ¢ ¤ § § § § ¨¨ ¨ ¨ £  ¨  63 Sergio Rojas: http://www.ula.

ve/ sergio/ ¡ .j i-1.  ¤ Figure 4: Finite element aproximation of the area of a circle £ i.j-1 i. .cecalc.j+1 i+1.An Introduction to Computational Fluid Dynamics 5 5.1 Finite Element Method (FEM) Intuitive introduction: the area of a circle . .j 64 Sergio Rojas: http://www.ula.j i.

some shapes (or combination of shapes) will represent the domain of interest more closely than others. When using more than one type of element in the representation of the domain.cecalc. The accuracy (difference between the true solution and the FEM solution) and convergence (accuracy as the number of elements in the mesh is increased) of the finite element solution depends on the element used and the problem being solved. into a mesh of only one type of elements or into one of more than one type of elements.An Introduction to Computational Fluid Dynamics A few words are in order: The domain of interest can be discretized. depending of its shape. error due to numerical computation. Sources of error can be attributed to: errors due to the approximation of the domain. Sergio Rojas: http://www. errors due to the approximation of the solution. In general.ve/ sergio/ ¡         65 . each kind should be isolated and its properties developed.ula.

algebraic equations will be solved to find the A conceptual difference emerges here from the finite difference 66 Sergio Rojas: http://www. and are known conditions. analytic functions. a system of ordinary differential equations will be solved for . which assumes that numerical solution of problems in science and engineering can be represented in the form:  (24)  is chosen to satisfy the boundary and initial where are unknown coefficients. For steady problems a system of .An Introduction to Computational Fluid Dynamics 5.ve/ sergio/ ¡ £ ¦¨   £ ¢ ¥¨ ¡ ¦¨ ¥¨ ¡ £ ¦¨ ¥¨ ¡ § ¨   ¨  ¨ ¨ ¨ ¨   ¦¨         £    ¡  ¢ ¢   § ¥¨ ¡ ¨ ¦¨ ¨     ¥¨   ¡ ¨ ¨ £  ¢ ¦¨ ¢  ¡ £ ¢ ¤ .cecalc.ula.2   Generalities FEM are casted into the broad class of numerical methods known as weighted residual methods. For time-dependent problems. often referred to as trial functions.

By this means. The coefficients   are determined by requiring: .ve/ sergio/ ¡ . On a are found. once the everywhere in the computational domain. (25)     £ ¦¨ ¢  £ ¢ ¡ ¦¨    ¡     ¢ ¥   ¥¨   ¡   ¥     ¡ ¢  ¨   ¨ ¨ ¡ ¨   ¨  ¨ ¨ Where is the residual obtained after substituting equation 24 into the differential equation being solved. a set of equations for are generated allowing theirs determination. Different choices the defines the particular type of for the weight (test) function weighted residual method being used.ula. where solution is found at nodal (discrete) points.An Introduction to Computational Fluid Dynamics methodology. The FEM formulation v´ ıa the ’s are chosen from the Galerkin Method is obtained whenever the same family of functions as the approximating (trial) functions of equation 24.    ¡ £ ¢   ¤ ¡   ¡   ¡ ¥¨ ¨ ¨ £  ¢ 67 Sergio Rojas: http://www. solution is known weighted residual method.cecalc.

68 Sergio Rojas: http://www.ula.ve/ sergio/ ¡ ¥ (26)      ¥¨ ¥ ¡       ¥ §     § © § ¨ ¡   § ¥¨ ¥    © ¨ . laminar (Poiseuille) flow in a pipe. elastic bars. on page 30): on       ¥ ¨    £ ¡ ¥¨    ¥¨  ¥   ¥ ¥¦ ¥ ¥ §¨ © ¨  As we know this differential equation governs one dimensional steady heat flow as well as other important physical and engineering phenomena like diffusion.cecalc. The set of equations 26 is known as the strong formulation of one dimensional heat flow.An Introduction to Computational Fluid Dynamics 5. etc.3 Steps of the FEM: a one dimensional model problem Let’s consider the problem of finding numerical solution of (compare with problem 5.

1 Formulating the weak form of the problem A version of the FEM formulation starts by establishing what is called the weak or variational formulation of the governing equation (in this case equation 26).ula. which can be obtained by multiplying equation 26 by an weight function and integrating the resulting equation into the arbitrary : interval   ¥¨ ¢ ¢ ¢ £  ¡ ¥¦     ¥ §¨ ©   (27)       ¥ ¨   £ ¡ ¥   ¥ ¥¨  ¨    ¥  §   ¥¨  ¨  ¥ £ ¤   ¥ using:         ¥¨    ¨    ¥ ¡ £ ¡   ¥¨    ¥¨ ¥¨  ¥¨  ¥¨  ¨  ¥  ¥ (28) ¤         ¥ ¥¨  £ ¡   £       ¥ ¥¨    ¥ ¥¨  ¥¨  ¥   ¥   ¥ 69 Sergio Rojas: http://www.ve/ sergio/ ¡ .cecalc.3.An Introduction to Computational Fluid Dynamics 5.

cecalc. Also.   ¢ £ ¤ £ ¢   ¢ ¢ ¢   ¥ (29) ¡     ¥ ¥¨ ¥¨   ¥ § ¢ ¢     70 Sergio Rojas: http://www.ula. The finite element is formulated based on the weak formulation of the governing equation basically because the weak form involves the use of approximating functions with only need to be differentiable once (the terminology of weak and strong forms is also related to this fact). equation 27 can be integrated to obtain: ¢ ¡   ¢ ¡       ¥¨   ¥¨     ¥¨  £ ¡     £ ¡  ¥   ¥¨ ¨   ¨    ¥       ¥ ¥¨ ¥¨   ¥ which is known as the weak (integral or variational) form of the one dimensional steady heat equation. the order of differentiation of the unknown(s) is lower in the weak form ( needs to be differentiable once) than in the strong form.ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics so.

There are situations on which this requirement is not fulfilled (Zienkiewicz and Taylor. The approximation must be able to represent an arbitrary constant value of the function being approximated. 1989). In many situations.cecalc. an expansion of the unknown in terms of a Sergio Rojas: http://www. Some requirements have been lay out to this regards: The approximation must be able to represent an arbitrary constant gradient of the function being approximated. given in this way an “elementwise” approximation of the unknown function.ula.2 Choosing approximating functions for the unknown As we have been talking about. FEM approach involves the splitting into smaller parts (finite elements) the region of interest for which one can establish an approximation for the unknown ’s.An Introduction to Computational Fluid Dynamics 5.ve/ sergio/ ¡             71 .3. The approximation of the function over element boundaries must be continuous.

cecalc. ] is divided into lineal elements.i.3. Consider the element with end points at and .2. 5. The unknown is §   ¡ £ ¥ §   ¥   ¡ ¥ ¥ ¥ ¢ ¥ ¡   ¥ ¢ ¥ ¦ 72 Sergio Rojas: http://www.ve/ sergio/ ¡ .j An Introduction to Computational Fluid Dynamics polynomial expansion is used for the elementwise approximation.1 One dimensional lineal elements £ ¢ ¤   £ ¢ ¥   ¥ © ¥ The one dimensional domain [ .ula.

functions of element ( ). The representation of the unknown . This means that once the geometry of the element is known.ve/ sergio/ ¡ .ula. given by equation 30a.An Introduction to Computational Fluid Dynamics represented in the form: (30a) ¦ £  £ and are known as the element shape In this formulation. separates the influence of geometry via the element shape function from the influence of physics given by the nodal temperatures .cecalc. the element shape function can be established directly. . Equation 30a approximates the £ ¢ ¡   ¢   ¢   ¥¨  ¢ ¢ ¥ § ¨   ¥¨ ¦ (30b) (30c) (30d) (30e)  ¥ ¥ £ ¦   ¢ ¥ ¨ ¢   ¥ ¢ ¥ ¦  ¥ ¢ ¥ £  ¢ ¥¨  ¦  ¥ ¢ ¥ ¦ £   ¢   ¢ £ ¥¨  ¢ ¢ ¥    ¨  ¦ ¢ £   ¢ ¢   £ ¥¨  ¢ ¥    ¨  ¦ ¦ £ ¢ ¦ ¥ ¥ ¨  ¨  ¢ ¦     ¢   ¦ 73 Sergio Rojas: http://www.

ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics function as an interpolation. between the function nodal values. a global shape function is defined in such a way that one global shape function is associated to each nodal point:   74 Sergio Rojas: http://www. defined by the element shape functions. Now.cecalc.ula.

cecalc.An Introduction to Computational Fluid Dynamics if in element 1    £ ¤ ¢ ¥¨  ¢ otherwise if if in element 1 in element 2 (31) if if in element 2 in element 3 £ ¤ ¥  ¢ ¥ ¨ ¢ ¡   ¢  £ ¤   ¢ ¥¨  ¥ £ ¦ £ £  ¤ ¢ ¥ ¢ ¥¨ ¥ ¨   ¦ ¦ ¡ £ £ otherwise  ¢   ¢ ¥ £ ¥ ¨ ¤  £ ¢ £  ¤ ¢ ¥ ¢ ¥ ¥ ¨ ¤  ¨ ¤  ¡ otherwise if in element 3 ¢ £ ¤ £ £  ¢   ¢ ¥¨  ¡ otherwise ¡ ¥  ¢ ¥¨  ¡ ¡  ¢ 75 Sergio Rojas: http://www.ula.ve/ sergio/ .

An Introduction to Computational Fluid Dynamics Now one can express the approximation of the function global shape functions:    ¢   ¢   ¢   ¢ in terms of the (32)     which can be written in the neat form:   ¢ ¥¨  ¢ ¥¨  ¢ ¡ ¢   ¢ ¥ § ¨ ¡ ¡ ¤ ¤ ¥ §  ¨  §  ¥¨ ¦ ¤ ¥ ¥ ¦ ¦ (33)          ¢ ¢ ¢ ¢ ¢ ¢ ¥¨  ¨ § ¢ ¥     ¦ ¢ ¤ ¡  ¦ ¢   ¤ ¢   ¡ £ ¦ ¥ ¥   ¦  §  § ¢ ¤ ¡  ©   ©   ¦  § ¢ § ¢ § ¢ § ¢ § ¢ § ¢ 76 Sergio Rojas: http://www.ve/ sergio/ ¡ .cecalc.ula.

Quadratic elements are constructed with three nodes by   ¥ § © ¡   ¥ §   ¥   ¡   ¥ £ ¢ ¥ § ¥ ¥ 77 Sergio Rojas: http://www.2.3.cecalc.An Introduction to Computational Fluid Dynamics 5.2 One dimensional quadratic elements £ ¢   £ ¢   ¥ Higher order elements can be easily constructed. In this case.ve/ sergio/ ¡ . the approximation of the unknown will contain terms of higher order than the linear ones.ula.

cecalc.ula.An Introduction to Computational Fluid Dynamics locating at each end of the element a node (this ensure continuity of ) across neighboring elements) and the third nodal point is located arbitrarily within the element (in practice it is usually located at the middle of the element). Along the element.ve/ sergio/ ¡ . the unknown is represented in the form:   (34a) (34b) (34c) (34d) (34e) £  £ £ notice that   ¢   ¢   ¢   ¥¨  ¢ ¥¨  ¢ ¥ § ¨ ¤ ¥¨ §   ¦ ¤ ¦   ¥ ¨ ¤ ¥  ¨  ¥ ¥ £ ¦  ¢ ¥ ¨ ¢    ¥¨  ¢ ¤ ¢ ¥ ¨  ¥ ¦   ¥ ¥¨  ¢ ¤ ¥ ¨  ¥ ¥ £   ¢ ¥¨  ¦   ¥ ¨ ¢ ¤ ¥  ¨  ¥ ¦   ¥ ¦ ¥ ¨ ¢ ¥  ¨  ¥ ¥ £ ¦  ¢ ¥ ¨ ¤    ¥¨ ¢ ¤     ¥   ¥¨ at nodal point i otherwise ¤ ¥ ¦ £  ¢ ¥ ¨ ¢ ¡   ¢ 78 Sergio Rojas: http://www.

cecalc. . Also. global shape functions are defined in such a way that one global shape function is associated to each nodal point: £ ¢ £ ¢ £ ¢ ¥ ¥ ¥ ¨  ¨  ¨  ¢ ¤ ¦ ¡ 79 Sergio Rojas: http://www.ve/ sergio/ ¡ .ula. and are the element shape functions of element ( ). .An Introduction to Computational Fluid Dynamics As before.

cecalc.ve/ sergio/ .ula.An Introduction to Computational Fluid Dynamics if in element 1    £ ¤ ¢ ¥¨  ¢ otherwise if in element 1 ¥  ¢ ¥ ¨ ¢ ¡   ¢    £ ¤ ¢ ¥¨  ¥ ¦ otherwise if if in element 1 in element 2 (35)  ¢ ¥ ¨  ¦ ¡  ¢  £ ¤   ¢ ¥ £ ¥ ¨ ¤  £ £  ¤ ¢ ¥ ¢ ¥ ¥ ¨ ¤  ¨ ¤  ¡ otherwise if in element 2 £ ¤ £ £  ¢   ¢ ¥ ¨ ¡ ¥  otherwise if in element 2 £ ¤  ¢ ¥¨  ¡ ¡  ¢   ¢ ¥¨    otherwise ¡ ¥  ¢ ¥ ¨   ¡   ¢ 80 Sergio Rojas: http://www.

An Introduction to Computational Fluid Dynamics Now one can express the approximation of the function global shape functions:    ¢   ¢   ¢   ¢   in terms of the (36)   ¢   which can be written in the neat form:   ¢ ¥¨  ¢ ¢ ¥ § § § § ¨ ¡ ¡     ¤ ¤ ¥ ¥ ¥ ¥¨  ¨  ¨  ¨   ¦ ¡ ¢   ¢ ¥ ¥ ¤ ¦ ¦ ¢ ¢ ¥ ¥          ¢ ¢ ¢ ¢ ¢ ¢ ¢ ¥¨  ¨ §       ¦ ¢ ¤ ¡    ¢ ¢ ¢   ¡ ¢     £ ¦ ¥ ¥ ¥ ¤ ¥ ¦   ¦  §  § ¢    ¤ ¡  ©   ©   ¦ (37)  § ¢ § ¢ § ¢ § ¢ § ¢ § ¢ § ¢ 81 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/ ¡ .

on page 69). A suitable choice of this weight function is obtained by the Galerkin method which (see end of   ¨ 82 ¨ ¥¨  Sergio Rojas: http://www.3 Choice of the weight function When finding the weak form formulation of the problem at hand (see equation 29.3.ve/ sergio/ ¡ .cecalc.2.3 One dimensional higher order elements Higher order elements can be introduced by properly numbering the nodes of the element.An Introduction to Computational Fluid Dynamics 5.ula.3. The element shape function is obtained from the Lagrange’s interpolation formula:            ¥¨   ¥ ¢ ¥¨  ¡ ¥        ¤ ¤ ¥ ¨  ¨   ¥ ¥ ¥ ¥¨ ¥ £ £  ¢ ¤            ¥ (38) ¢ ¥ ¨         ¥¨  ¡ ¥   ¨   ¥¨ ¥ ¥ ¥ ¥¨ ¥ ¤ (n is the order of the element) ¤ ¤ ¤ ¤ ¤ ¤ £          ¤ ¥ ¦ 5. an arbitrary weight function is introduced to get equation 29 and that needs to be determined.

  83 Sergio Rojas: http://www. Loosely speaking.2) is an example of the weighted residual method that requires that the integral of the residual ( ) of approximating an exact solution times the weight function in the region of interest be zero (see equation 25.4 Putting all together As we have seen. the Galerkin method is expressed by saying that weight function = trial function   5.ula.ve/ sergio/ ¡ . For our model problem 26.An Introduction to Computational Fluid Dynamics section 5. the basic steps in the finite element formulation we are using involves three step: Find the weak formulation of the problem.cecalc. on page 67).

ve/ sergio/ . Choose the weight function according to the Galerkin method: (41) ¡   ¥¨  ¢ ¥¨  ¢ ¥ § ¨ ¡ ¡ ¤ ¤ ¥¨ ¥¨ §  §   ¦ ¢   ¦ ¥¨  84 Sergio Rojas: http://www.ula. we have found: ¢ ¡   ¢ ¡       ¥   ¥¨     ¥ ¨  ¨  £ ¡ £ ¡     ¥¨  ¥¨    ¥ ¥ ¥¨     ¥¨  ¨       ¥ Make an elementwise approximation over the entire domain of the unknown function.An Introduction to Computational Fluid Dynamics on page 68. such as: (40)     ¢   ¢   ¢   ¢   ¢ £ ¤ £ ¢   ¢ ¢ ¢   ¥ (39) ¡     ¥ ¥ ¥¨   ¥ §   ¨   ¢ ¢     ¢   (see equations 32 and 36 on pages 76 and 81 respectively).cecalc.

and using the fact that ¨   ¥¨        (42)   ¨ § ¢ § ¢    ¥¨        85 Sergio Rojas: http://www.     ¡ ¥ ¢             ¢ ¢ ¢ ¢ ¢ ¥¨  ¨ §   ¢ ¢ ¢ £     ¡ ¦    ¥ ¥ ¥ ¦  §    §     ¡     ©   ©   ¦  § ¢  §¡ § ¨ ¨ ¨ ¨ ¨ ¢ § ¢ § ¢ § ¢ § ¢     ¢ ¢ © © is an arbitrary scalar function ( ).ula. .cecalc.An Introduction to Computational Fluid Dynamics So.ve/ sergio/ ¡ . the matrix is Since arbitrary. to continue with the development of equation 39. . we’ll consider the following:     ¡ ¤ ¢   ¢ ¥ ¥ . Inserting equation 42 into equation 39.

cecalc.ve/ sergio/ ¡ ¥  ¥¨ ¥¨ ¥¨      (44) ¥ ¥¨  .ula. we obtain: ¢     ¥   ¥ © ¥¨ ¡   ¡ £ ¥¨ ¥¨   ¥¨ £ ¨ ¢     ¡ ¢ ¥ ¨ ¡ ¢ ¢ ¢ © ¢ ¢ ¨   ¨   or 86 Sergio Rojas: http://www.(43) ¡ ¢ ¢ ¢           ¡ ¢ ¥¨ ¢ ¢              ¥ ¥¨     ¡      ¥ ¥¨    ¥¨ ¥ ¥¨       ¥ ¨   ¡ £  ¨ ¨ £ ¡ ¢ ¢ ¢ ¨ ¢ ¡ ¢ £ ¨ ¥¨ ¨  ¢ ¢ ¢ ¢ ¢ £ ¨ ¨ ¨      §   ¨      §   An Introduction to Computational Fluid Dynamics ¥   is independent of x.

An Introduction to Computational Fluid Dynamics since this expression should hold for arbitrary ¢ ¡ ¨ ¨ matrices.ula.ve/ sergio/ ¡ . This expression could be written in the more compact familiar form: ¢ £ ¢   ¢ ¢ ¢ (45) ¡ ¨ ¢ ¥¨ ¥¨   ¥ § ¢ ¢     87 Sergio Rojas: http://www.cecalc. one gets ¢ ¡       ¨   ¥¨     ©   £ ¡ © ¢ £ ¡ ¥¨  ¥¨      ¥      ¥¨ ¨  ¥  ¥¨ ¥ which is the required finite element formulation.

together with the applicability of the Galerkin method to any differential equation and the realistic prediction obtained by such approach are the primary reasons for its adoption in the FE formulation.ula.ve/ sergio/ ¡     ¡ ¨ ¨ ¡ (47) (48)    © £ ¡ ©    ¥¨  ¨  ¥   ¥ ¢ ¢  ¡ ¡ ¡ § ¡ ¢ ¡       ¢ (49) ¢ ¢ ¥¨    ¨  ¡ ¢ £ ¡ ¥¨  ¨  ¥   ¥¨  ¡     ¥ £   ¢ (50) ¡ ¨  ¡ ¢ ¥¨   ¥¨    ¥  ¢ ¢ ¢ .An Introduction to Computational Fluid Dynamics (46) ¢  Let’s note that the symmetry of K is a consequence of the Galerkin method.cecalc. Let’s write 88 Sergio Rojas: http://www. This fact.

.ula. .cecalc.ve/ sergio/ ¡   (51) § ! . ¨ ¦§ ¡   ¦ § ¦ ¥¤ ¢ ¡   89 Sergio Rojas: http://www.¨    ¦ ¨   ¦ ¨ § §  ¨ § ¡   ¦ § ¨ ¦§ ¡ ©  ¦  ¨ § ¥ ¥       ¦ ¨ ¨ §  ¦  ¨ § ¡    ¦   ¦ ¡ . . §    ¦ § ¥ © ¨ § ©  ¦  ¦  ¨ ¨ § § ¦§ ¦ ¦§ ¦ ¥ ¢ £ £¥ £ £ £ £ ¡ ¡ ¢ ¢ §  ¦§ ¦ ¢  ¦ §  § . ¥ ¦ ¢ §  § §  ¦ ¢ ¦§ ¦§ ¦ ¢      ¦ ¨ § §  ¨ § ¡   ¦ § explicit expression for equations 46-50: An Introduction to Computational Fluid Dynamics ¨ ¦§ ¥ © ¨ §   ¦ ¨ § © §   ¦ ¦ ¢ ¢ ©    ¦ ¦ ¥ ¦§ ¡ . . . .

.cecalc. .  ¡ ¥¨  ¡ ¢ ¢ ¥¨ £ ¡ ¢ ¢ ¢ ¢ ¢ ¢ £ £ ¥ ¢ ¢ ¢  £ £ £ ¨  ¡   ¥ ¨  ¥¨ ¢     ¢  ¢ An Introduction to Computational Fluid Dynamics ¡   ¥ ¡ ¡ ¡  ¨  ¥ ¡ ¡    ¡ ¨ ¥ ¨  ¥ ¨ ¡ ¡  ¡   ¥ ¨  ¢ ¡   ¡ ¡ ¥ ¨  ¥ ¤ ¥ ¥ ¥ ¥ ¥ ¦ ¥ ¨ ¡ ¡  ¥¨ ¢  ¡   ¥¨ ¡  ¥¨ ¡   ¡ ¥¨ £  ¥¨ £ ¡  ¥¨ ¡  £ ¥¨ ¢   ¡ ¥¨ ¡ £  ¥¨    ¥¨ ¡  £ ¡ ¥¨ ¡    ¥ ¢ ¡ ¢ ¢ ¨  ¥ ¨  ¡ ¢ ¢ ¢ ¢ ¢ ¢ ¢  £ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ ¢   £   ¡ ¡ 90 Sergio Rojas: http://www. .ula. . . . . .¥ ¥ ¥ ¥ ¥ ¥ ¡   ¥¨ ¢ ¢ ¢ ¢  ¤ ¦ ¤ ¦ ¥¨ ¢ ¢ ¢ ¢        ¡ ¥¨   ¡ ¢ ¥¨   ¡ ¥¨ ¥¨ ¡ ¡ ¢ ¥ ¨ ¡   ¡ ¥¨   ¡ ¥ ¨    ¥ ¥ ¥ ¥ ¥ ¥ (52) ¡ .ve/ sergio/ ¡ ¥¨  ¡ ¥¨  ¥¨  ¥¨ .

ve/ sergio/ ¡ . now one can make use of the boundary condition of our model problem (equation 26.cecalc. on pages 78 and 79 respectively): at nodal point i otherwise .ula. from which we obtain: (53a) (53b)     £  ¢ ¢ otherwise  ¢ ¥¨  ¢ ¡ ¥ ¨ ¢ ¡   ¢  ¢ ¥¨     ¡             ¥¨  ¢     ¢ ¢ ¥ § ¨ ¥         ¥¨     ¡      ¡ ¡    ¥¨  ¡     ¢ ¡ ¥¨ © ¥ ¡ ¡ 91 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics where we have made use of the shape function properties (see equations 34e and 35. on page 68). if in element 1        £ ¤ ¢ ¥¨  ¥ to continue.

cecalc. ¥ ¨ . ¥ ¡ ¢  ¨ . .(54) ¥ ¥ ¥ ¥ ¥ ¥ ¤ ¦   ¡   ¥ ¤ ¢     ¡ ¡     ¡ ¡ ¥¨ ¡ ¢ ¥ ¨   £ and  ¡   ¤  ¥ ¥ ¥ ¥ ¥ ¥ ¥¨ ¥   ¥   ¥ ¥ ¦   £  ¡ ¢ ¢ ¢ ¢ ¢ ¢ £ . (55) . . for we obtain. ¥¨  ¨    ¦ § ¢ ¡ ¡ ¢ ¢  ¥¨ ¥ ¢ ¢ ¡ ¢     ¥¨ ¨ ¡  § ¥ ¥ ¥ ¥ ¥ ¥ ¥    ¨   An Introduction to Computational Fluid Dynamics where we have used the fact that   ¢ ¡ ¤     ¥  ¢ ¨ ¡  £ ¢   ¡ ¡     ¢ ¡ £  £ ¡ ¢ ¢ ¢ ¢ ¢ ¢ £  ¡ ¡ Last. . ¥¨ § ¢ ¢ ¡ ¢ ¢ § ¢ ¢ ¢ ¢ ¢ ¢ § ¢ £  ¢ ¡ ¥¨ ¡  ¢ ¡ 92 Sergio Rojas: http://www. . .ula.ve/ sergio/ ¡ ¥¨ ¡ ¤ ¢ ¦    ¥¨ © ¢ . .

and 55.Now. . can be written in the form: ¥ !   ¢ £ £ £ £ £ £      ¤   ¦ ¢ §  § ¡ ¤ £¦ © ¡ ¡ ¢ § £ ¢ ¢ §  §   ¢ ¡ . using equations 51. . ¦ ¦ ¦ ¥ ¢ £ £¥ £ £ £ £ ¢ An Introduction to Computational Fluid Dynamics     ¦ ¡  ¨ ¢ ¤ £¦ ¥     ¢ § ¢ ¦ ¥¤ ¢    ¢ ¡   !  . .cecalc. equation 46. £ ¢   ¢       ¡            £ ¢   ¢ ¡  £ £ £ £ £ £ ¤  £¦  ¡ ¡ ¢ ¢ £ £ £ £ £ £ ¡  £  ¢ . denoting the elements of matrix by . .   ¡ ! . . .ve/ sergio/ ¡ §  ¢     ¢ . . 54.ula. ¡  ¢ ¡  ¤ 93 Sergio Rojas: http://www. . . .       ¡ ¢ £ ¨ !     ¢ ¢         ¡ ¡ ¡   ¢ ¦        ¡        ©   ¦ ¡   £    ¡ ¢ £ ¢ ¢ £ £ ¢   £ ¢  £ ¢     £¦    ¢ . (56) . . .

ula.cecalc. let’s find the numerical solution of the one dimensional problem: on     ¥  ¨ ¥    ¡ ¢   ¥¨  ¥¨ ¥  ¥ ¨ ¦     ¥   with: (57a)  ¡   ¥¨  ¡ ¢£  ¡ £  £  ¢ ¥¨  ¢¨  94 Sergio Rojas: http://www.5 One dimensional illustrative example (using Mathematica) By using the ideas of the previous section.ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics 5.

page 30.An Introduction to Computational Fluid Dynamics subject to bc’s 6.ula. where: ¢ ¨  £         the exact solution is given by: (57c)   ¢ A Mathematica code implementing previous ideas to solve this problem is as follows:      ¡    (57b)                ¡        ¥  ¨    ¡ 95 Sergio Rojas: http://www.cecalc.ve/ sergio/ ¡ .

name].plot]. Clear[guardar]. (* -------*) MySavingPlot[name_. #3]. ExponentFunction-> (If[-1<#<1. SetDirectory[oldDir] ](* close if *)](* close Module *).plot].An Introduction to Computational Fluid Dynamics (*-------------------------*) (* PREAMBLE *) (* -------*) RegularForm[x_]:= OutputForm[NumberForm[TableForm[x//N]. plot]. Null. (* -------*) Needs["Graphics‘Legend‘"]. NumberFormat->(If[#3=="". plot_] := Display[StringJoin["!./psfix_3. (* -------*) (* MySave[name_.ve/ sergio/ ¡ . "E". guardar = Input["\t\t\t Hit 1 + ENTER to save. MySave[name. SequenceForm[#1. #]&). #3]]&)]] . oldDir}. *) MySave[name_. 96 Sergio Rojas: http://www. plot_] := Display[name. (* -------*) FESavingPlot = Directory[]. If[guardar == 1.0 > ". SequenceForm[#1. oldDir = Directory[]. plot_] := Module[{guardar. SetDirectory[FESavingPlot].cecalc.ula. otherthing to continue "].

ula. Nglobal.0. InternalNodes = Input["How many INTERNAL nodes (order of the element)? "]. InternalNodes. MainNodes. with [i] representing the node and [j] representing the element. INTERNAL nodes by xx[i][j]. j. x. f. An example of 3 GLOBAL nodes [*] (defining 2 elements) with each element having 2 INTERNAL nodes (. MatrixLocal.---*---. Xb.---. Xa = 0. MainNodes = Input["How many MAIN (global) nodes (elements = Nnodes-1)? "].ve/ sergio/ ¡ . nglobal.---* 97 Sergio Rojas: http://www. ********************************************) Clear[Xa.0.) can be represented as: *----. Nlocal. TotalNodes. (*-------------------------------------------------------------------Global nodes are designed by X[i]. Dlocal.An Introduction to Computational Fluid Dynamics (* -----------*) (* END PREAMBLE *) (* -----------*) (******************************************* Piece wise functions are best defined using Which[] because the derivative operator D[] knows how to deal with Which[] properly. xx.cecalc. Xb = 1. Kglobal]. jj.---. X. K1. Klocal. i. Dglobal.

Xa)/(MainNodes . xx[1][j] = X[j].1) Internal nodes define internal elements of same length = (X[j+1] .X[j])/(InternalNodes + 1) ---------------------------------------------------------------------*) X[1] = Xa.ve/ sergio/ ¡ . ---------------------------------------*) (* ------------------------------------------*) (*-------------.An Introduction to Computational Fluid Dynamics Global elements have same length = (Xb . to (InternalNodes + 2) *** for which xx[InternalNodes + 1][j] = X[j+1] ***) xx[i_][j_] := X[j] + (i-1)*(X[j+1] . xx[i_][j_] := X[j] ](* Close Which *). (** *** Here [i] can go from ONE.1).LOCAL SHAPE function of node j on element i ----------*) (* ------------------------------------------*) 98 Sergio Rojas: http://www. X[i_] := X[i-1] + (Xb . True. xx[i_][j_] := X[j] + (i-1)*(X[j+1] . (*-----------------------------------Which[ InternalNodes != 0.ula.X[j])/(InternalNodes + 1).X[j])/(InternalNodes + 1).Xa)/(MainNodes .cecalc.

2. [j] for example.b. Nlocal[2][j][x]. N) ** ---*) 99 Sergio Rojas: http://www. 3. b = 1. can be labeled as *** Nlocal[1][j][x].. (* ------------------------------------------*) (*-------------GLOBAL SHAPE functions ----------*) (* ------------------------------------------*) (*-** ** The way how this is done below is by counting the local nodes ** and defining a "global" label for each node (1.ula.. .. Expand[a/b]].. a = a*(x-xx[k][j]). Do[ Which[ k != i. a = 1..k}. {k. The local shape *** function for a particular element.An Introduction to Computational Fluid Dynamics (** *** Each element will has (InternalNodes + 2) NODES.1. b = b*(xx[i][j]-xx[k][j]) ].ve/ sergio/ ¡ .Nlocal[InternalNodes + 2][j][x] ***) Nlocal[i_][j_][x_] := Module[{a...InternalNodes + 2}].cecalc.

100 Sergio Rojas: http://www. True. Evaluate[Nlocal[InternalNodes + 2][j-1][x]].cecalc. 0] /. If[ (i == (InternalNodes + 2) && j != (MainNodes-1)). (********* NO GLOBAL FUNCTION FOR THIS NODE ******) (* jj = jj -1 *). (Hold[Which][ x >= Evaluate[X[j-1]] && x < Evaluate[X[j]]. jj = jj + 1. Hold[Which]->Which). Hold[Which]->Which) ](*Close Which *). (* *) (* FORMING GLOBAL SHAPE FUNCTIONS USING GLOBAL NUMERATION OF NODES *) (* --------------------------------------------------------------. i<=InternalNodes + 2.*) jj=0. Do[ For[i=1. True. i = i + 1. Evaluate[Nlocal[i][j][x]].An Introduction to Computational Fluid Dynamics Nglobal[i_][j_][x_] := Which[ (i == 1 && j != 1).ula. (Hold[Which][ x >= Evaluate[X[j]] && x <= Evaluate[X[j+1]]. 0 ] /. x >= Evaluate[X[j]] && x <= Evaluate[X[j+1]]. True.ve/ sergio/ ¡ . Evaluate[Nlocal[i][j][x]].

*) Clear[lambda.1.cecalc. (* "Load vector" for element k.An Introduction to Computational Fluid Dynamics nglobal[jj][x_] := Evaluate[Nglobal[i][j][x]].(MainNodes-1)}](* Close Do *). {j. A2. A1. lambda := -1. Q1. i is the internal node *) (* --------------------------------------------------.DERIVATIVE OF LOCAL and GLOBAL shape functions -------*) (* Here it is better to use equal (=) instead of "colon equal" ( := ) *) (* in the definition of derivatives *) (* *) Dlocal[i_][j_][x_] = Hold[D[ Nlocal[i][j][x].ula. (* *) (* -------.ve/ sergio/ ¡ . Akfunc.0). ].0.x]]. Dglobal[i_][j_][x_] = Hold[D[Nglobal[i][j][x]. Q1[x_] := -((lambdaˆ2)*Exp[lambda*x])/(Exp[lambda]-1. alfa2. (* This takes care of the increase of jj at the main nodes to avoid a double counting of the Global shape functions at such nodes *) ] (*Close For *).*) (* USER INPUT *) (* ---------. 101 Sergio Rojas: http://www. beta2]. alfa1.x]]. beta1.

ExactT[x_] := (Exp[lambda*x]-1.{x. {i. A2 = 0. fbcXa = -(A1/beta1)*Akfunc[Xa].ve/ sergio/ ¡ .1. Clear[TheBcAtNodeXa.0 . A1 = -1. beta1 = -(Exp[lambda]-1.cecalc. fbcXb = (A2/beta2)*Akfunc[Xb]. Integrate[Q1[x]*Nlocal[i][k][x].*) Do[ Do[ Flocal[i][k] = f1[i][k].InternalNodes + 2}] .ula. (* Boundary conditions *) (* ------------------.X[k]. alfa2 = alfa1 .0)/(Exp[lambda]-1.1. f1[i_][k_] := \ Module[{x}. TheBcAtNodeXb]. TheBcAtNodeXa = (alfa1/beta1)*Akfunc[Xa].{k. alfa1 = -Exp[lambda] ..*) Clear[fbcXa.An Introduction to Computational Fluid Dynamics Akfunc[x_] := 1. . ExactT].beta1.(MainNodes-1)}]. beta2 = .0).X[k+1]}]]. 102 Sergio Rojas: http://www. fbcXb.0)/lambda. TheBcAtNodeXb = (alfa2/beta2)*Akfunc[Xb]. (* Local "Load Vector" Element [i] for element k *) (* --------------------------------------------.

K1[i_][j_][k_] := Module[{x}.cecalc. K1[i_][j_][k_] := Module[{x}. {x. (****-----------------------------------------------------------------****) (****-----------------------------------------------------------------****) Do[ Do[ Do[ Klocal[i. {x.X[k+1]}]]. If[j != i.*) Which[ InternalNodes != 0.X[k].ula. Integrate[ ReleaseHold[Dlocal[i][k][x]]*Akfunc[x]*ReleaseHold[Dlocal[j][k][x]].i][k] = ReleaseHold[K1[i][j][k]] 103 Sergio Rojas: http://www. True.X[k].j] for element k *) (* ---------------------------------------. Integrate[Dlocal[i][k][x]*(Akfunc[x])*Dlocal[j][k][x].ve/ sergio/ ¡ . (* Using the fact the K matrix is symmetric *) Klocal[j.An Introduction to Computational Fluid Dynamics (* Local Matrix Element [i.X[k+1]}]] ].j][k] = ReleaseHold[K1[i][j][k]].

Nj+1] + KL[1.i. ... ** ** Nj Nj+1 Nj+2 .j][k]. .2] ** . {i. Nk the contribution of the local element J to ** global matrix K is as follows: ** ** K[Nj..1. Nk ** ------------------------------------------------ 104 Sergio Rojas: http://www.1. Nj+1.Nk] = K[Nk..ve/ sergio/ ¡ .InternalNodes + 2}] ...InternalNodes + 2}] .{k..Nk] + KL[(Nk-Nj)+1.{j.1] ** K[Nj.(MainNodes-1)}].An Introduction to Computational Fluid Dynamics ] ...1. ** K[Nk...Nj] + KL[1...Nj+1] = K[Nj. MatrixLocal[k] = Table[ Table[Klocal[i.. ** This is necessary because if for example element j is between global ** nodes Nj.cecalc.. (****-----------------------------------------------------------------**** ** ** To find K_global from K_local one needs to find between which global ** nodes a particular element (to which K_local belong to) is located.{j.InternalNodes + 2}].InternalNodes + 2}].(Nk-Nj)+1] ** ** The drawing belong may be useful to see the this..{i. .Nj] = K[Nj..1.ula..

StartOfElement. . FLoadGlobal.(Nk-Nj)+1] ** .1) + MainNodes ** ** It is not hard to see that element j is found between the ** global nodes: ** ** StartOfElement[j_] := InternalNodes*(j-1) + j .ula. KL[(Nk-Nj)+1. EndOfElement. KcontributionOfElement. ..2] KL[2. The total number of (global) nodes is: ** ** TotalGlobalNodes = InternalNodes*NumberOfElements + MainNodes ** = InternalNodes*(MainNodes . ** ... | .2] KL[2. .3] .(Nk-Nj)+1] ** Nj+1 | KL[2. ** EndOfElement[j_] := StartOfElement[j] + InternalNodes + 1 .. KL[1. KL[2...1] . 105 Sergio Rojas: http://www. ** Nk | KL[(Nk-Nj)+1. . FloadVector.ve/ sergio/ ¡ .cecalc. . | .1] KL[1. TotalElementNodes.3] . | .2] KL[1.An Introduction to Computational Fluid Dynamics ** Nj | KL[1... ** ****-----------------------------------------------------------------****) Clear[NumberOfElements. ** . TotalGlobalNodes. .(Nk-Nj)+1] ** -----------------------------------------------** ** Now. . Kglobal. . .. FloadContributionOfElement.

Temperature.{l. NumberOfElements = MainNodes .An Introduction to Computational Fluid Dynamics GlobalMatrixK.1.0 .m.ula. (* Contribution of Element k to Global Load Vector Fload *) (* ----------------------------------------------------. Ftotal.StartOfElement[k]. EndOfElement[j_] := StartOfElement[j] + InternalNodes + 1 . i = 0.*) Do[ Do[Kglobal[i.1 .1. FLoadGlobal[l] = FLoadGlobal[l] + Flocal[i][k].j] = 0.{i.1. {i. TotalElementNodes = InternalNodes + 2. eq1]. StartOfElement[j_] := InternalNodes*(j-1) + j . Do[(* l Do *) i = i + 1. 106 Sergio Rojas: http://www.i}.TotalGlobalNodes}]. Do[FLoadGlobal[i] = 0.0 . eq. TotalGlobalNodes = InternalNodes*NumberOfElements + MainNodes .cecalc.TotalGlobalNodes}].{j.TotalGlobalNodes}].EndOfElement[k]}]].ve/ sergio/ ¡ . (* Initializing Kglobal and FLoadGlobal to Zero *) (* -------------------------------------------. eqs.*) FloadContributionOfElement[k_] := Module[{l. .

. Do[(* m Do *) j = j + 1.1] .1.TheBcAtNodeXa.TotalGlobalNodes] + TheBcAtNodeXb. Do[ KcontributionOfElement[k]. j = i .j}. Kglobal[TotalGlobalNodes. Do[(* l Do *) i = i + 1.EndOfElement[k]}].EndOfElement[k]}]].{l.StartOfElement[k].m]].1.j][k]. Kglobal[l.m.l] = Kglobal[l.An Introduction to Computational Fluid Dynamics (* Contribution of Element k to Global Matrix K *) (* -------------------------------------------.TotalGlobalNodes] = Kglobal[TotalGlobalNodes.ve/ sergio/ ¡ .l.NumberOfElements}].*) KcontributionOfElement[k_] := Module[{l. Kglobal[m. 107 Sergio Rojas: http://www.1] = Kglobal[1.{m. If[ m != l.ula. i = 0.i.m] = Kglobal[l.m] + Klocal[i. .{k.cecalc. (* Finding Contribution of each Element to Global Matrix K *) (* ------------------------------------------------------.*) Kglobal[1.

(* --------------. (* Boundary conditions *) (* ------------------.TotalGlobalNodes-1}].1.MatrixForm[ Ftotal = Fboundary + FloadVector ]].An Introduction to Computational Fluid Dynamics Print["Global_K_Matrix = ".TotalGlobalNodes}].{i.j]. (* Finding Contribution of each Element to Global Fload *) (* ---------------------------------------------------. {i.2.TotalGlobalNodes}]]].{j. (* --------------.NumberOfElements}].MatrixForm[ GlobalMatrixK = Table[ Table[Kglobal[i.cecalc.{k.{j.{i. Print["F_Load = ".MatrixForm[ Fboundary = Flatten[{fbcXa.*) Temperature = Table[T[i].1.TotalGlobalNodes}]]].ve/ sergio/ ¡ .*) Do[ FloadContributionOfElement[k].1.ula.fbcXb}]]] .1.Table[0. 108 Sergio Rojas: http://www.*) Print["F_total = F_boundary + F_Load = ".1.MatrixForm[ FloadVector = Table[ FLoadGlobal[j].*) Print["F_boundary = ".TotalGlobalNodes}].

{i. Print[" FEsolofT[x] = ".Temperature .*) Clear[Tnodes].t2.*) Clear[t1.TotalGlobalNodes}].TotalGlobalNodes}] /. (* --------------.1. FEsolofT[x_] := Sum[nglobal[i][x]*T[i]. Tnodes = Flatten[ Solve[Table[eq[i] .cecalc.TotalGlobalNodes}].ula.*) Print[" "]. (* --------------. Table[T[i].TotalGlobalNodes}]] ]]. (* --------------. Tnodes .TITLE].*) eq1 = GlobalMatrixK. ExactT[x] ]. (* --------------. {i.Ftotal .1. 109 Sergio Rojas: http://www. FEsolofT[x] ].{i.An Introduction to Computational Fluid Dynamics (* --------------. (* --------------.{i.1.ve/ sergio/ ¡ . Print[" Tnodes = ".*) Do[ eq[i] = eq1[[i]] == 0. Print[" "].1.*) Clear[FEsolofT]. Print[" ExactT[x] = ".

1].ula. {RGBColor[1. AbsoluteThickness[2]} }. -1.7. "Exact Solution"}."Temperature"}.2}.MainNodes]].Xa. InternalNodes]].Xb}. Dashing[{.02}]. "". Frame -> True.""}. LegendPosition -> {-1.t2]. 0]. PlotRange -> All.An Introduction to Computational Fluid Dynamics t1=ToString[StringForm[ "Finite Element Solution using ‘1‘ Main". . (* PlotLabel -> TITLE.5}. 110 Sergio Rojas: http://www. 0. PlotLegend -> {"Finite Element Solution".{x. FrameLabel -> {"". TITLE.ve/ sergio/ ¡ . DisplayFunction -> $DisplayFunction. 0. DisplayFunction -> Identity ](* close Plot *). AxesOrigin -> {0.cecalc.Evaluate[ExactT[x]]}. AxesLabel -> {"x". AbsoluteThickness[2]}. TITLE = StringJoin[t1. t2=ToString[StringForm[ " Nodes and ‘1‘ Internal Nodes ". FrameTicks -> False (* no tick marks around the frame *). LegendSize -> {1. *) PlotStyle -> {{RGBColor[0.0}]. FEplot = Show[Plot[{Evaluate[FEsolofT[x]]." \n ".

0}. Ttitles. (* --------------.An Introduction to Computational Fluid Dynamics (* SAVING THE PLOT *) (* --------------. Clear[t1. FEsolAtval. ErrorPlot = Show[ ListPlot[pairstoBeplot.t2]. xval = Table[Random[Real. FEplot]. Prolog -> AbsolutePointSize[4].TITLE]. TITLE = StringJoin[t1. DisplayFunction -> Identity ](* Close ListPlot *). ExactTAtval = Map[ExactT." \n ".xval]. FEsolAtval = Map[FEsolofT.ula.xval]. ExactTAtval.*) CLear[xval.cecalc. InputString["\t \t \t Hit Return to continue "]. InternalNodes]].MainNodes]]. AxesOrigin -> {0. RelativeError = Abs[(ExactTAtval-FEsolAtval)/ExactTAtval].*) Print["\t \t *** Saving Finite Element solution Plot *** "]. values.{50}]. table ]. (*-------------------------*) pairstoBeplot = MapThread[List.RelativeError}]. t2=ToString[StringForm["Nodes and ‘1‘ Internal Nodes ". 111 Sergio Rojas: http://www.ve/ sergio/ ¡ .t2. t1=ToString[StringForm["Relative Error using ‘1‘ Main".Xb}].{xval.ps". RelativeError.{Xa. MySavingPlot["FEplot.

RelativeError}. MySavingPlot["ErrorPlot.ve/) we have available ABAQUS.cecalc.""}. FrameLabel -> {"x".ErrorPlot].*) Print["\t \t *** Saving Relative Error Plot *** "]. Print[table = RegularForm[TableForm[ MapThread[List. Error" }. (* --------------. AxesOrigin -> {0. ExactTAtval. values = { xval.Part[values.ve/ sergio/ ¡ .ps". TITLE. an engineering simulation software to perform FE computations of 112 Sergio Rojas: http://www.ula.{i. "Abs[(ExatT-FEsolofT)/ExactT]".4}]] ]]]. "Rel.*) At CeCalCULA (http://www. (* SAVING THE PLOT *) (* --------------.0}]. DisplayFunction -> $DisplayFunction.*) (* Take the comments to print the values in a table *) (* ---------Ttitles = { " x ".ula.An Introduction to Computational Fluid Dynamics Frame -> True. " FEsolofT ".i]}.1. InputString["\t \t \t Hit Return to continue "].i]. ---------.cecalc. " ExactT ". FEsolAtval. Table[{Part[Ttitles.

ve/ sergio/ ¡ . The community currently using this software are faculty member of the Universidad de Los Andes and other researchers throughout the country.cecalc.ula. 113 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics problems ranging from relatively simple linear analyses to the most challenging nonlinear simulations.

cecalc. Here are a few examples: 114 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics 6   Some aspects of grid generation The numerical computation of fields involving complex geometries implies computational boundaries that do not coincide with coordinate lines in physical space.ula.ve/ sergio/ ¡ .

ve/ sergio/ ¡ .cecalc.ula.j An Introduction to Computational Fluid Dynamics i.j 115 Sergio Rojas: http://www.i-1.

ve/ sergio/ ¡ .ula.cecalc.An Introduction to Computational Fluid Dynamics 116 Sergio Rojas: http://www.

ve/ sergio/ ¡ .cecalc.ula.An Introduction to Computational Fluid Dynamics 117 Sergio Rojas: http://www.

ula.An Introduction to Computational Fluid Dynamics Dealing with such difficulty is done by using a mapping or transformation from physical ( .    ¥¨   ¡ ¥ ¡ ¥¨ ¡ ¨     ¨ ¨ ¨ ¨ ¨ The transformation is unique if 118 ¢ Sergio Rojas: http://www.ve/ sergio/ ¡ ¢   ¤ ¤   £ £  ¨ ¡ ¢ ¢ ¡ ¡ ¢ £ ¡ ¡ £ ¡ ¡ ¡ ¡ ¡ ¢ ¤ ¤ ¢ ¢ £ ¡ ¡ £ ¡ ¥ ¥ ¡ ¡ ¡ ¢ £ ¡ £ ¡ ¡ £  . and its inverse can be uniquely  ¢ (58) ¤ ¥ ¤ ¥ ¥ ¦    ¦  .cecalc. . on page 26). The existence of a unique single valued relationship among the coordinates is defined by the Jacobian ( ) of the transformation.   ¥   ¡ ¢ ¤ £   . That is. . . ) space such that a distorted region in physical space is mapped into a rectangular region in the generalized coordinate space (see figure 3. ) space to a generalized curvilinear coordinates ( .

cecalc.    The elements of ¥ ¥ ¡ ¡ ¨ and ¢ £ ¤ ¨ ¨ ¨   ¨   £   ¢ ¤ ¨ ¨ ¨ ¢ £ ¤ ¨   ¢ ¡ ¢ ¡ ¡ ¢ ¤ ¡ ¡ ¡ ¡ ¢ £ £ ¨  ¢ ¡ ¡ ¥ (59) ¤ ¡ ¥ £     ¥ are related by: ¢ ¡ ¢ ¤ ¥ £ ¡ ¡ ¡ ¡ ¦ ¡ ¡ £ £ ¡ ¡ £ ¢ ¤ ¥ ¨       119 Sergio Rojas: http://www. .An Introduction to Computational Fluid Dynamics obtained: .ve/ sergio/ ¡ .ula.

   ¡ ¡ ¡ ¡ ¡ ¤ ¢ ¤ ¤ ¢ ¡ ¡ ¡ ¡ ¡ ¤ ¢ ¢ ¤ ¤ ¡ ¡ ¡ ¡ ¤ ¢ ¤  ¨    ¨    ¨   ¥ ¡                   ¡   ¡ ¡ ¥   ¡ ¢ ¤ £ 120 Sergio Rojas: http://www. This equations are useful to evaluate numerically the Jacobian ( ) whenever is necessary based on the generalized coordinate grid.An Introduction to Computational Fluid Dynamics ¡ ¡ ¢ ¢ ¡ ¡ £ ¡ ¡ ¡ ¡ ¡ £ ¡ ¡ £ ¢ £ ¡ ¢ £ £ £ £    .ve/ sergio/ ¡ . . ) coordinates are related to derivatives in the generalized ( . . . ) curvilinear coordinates by a relation of the form:   ¡ ¡ ¡ ¡ ¡ ¢ ¥ ¥ ¤ ¤ ¡ ¡ ¡ ¡ ¡ ¢ ¥ ¤ ¤ ¥ ¡ ¡ ¡ ¡ ¡ ¢ ¥ ¥ ¤ ¤  ¨    ¨    ¨   ¥ ¡               ¡ £ ¡ £ £ ¡ ¢ £ ¡ ¢ £ ¡ ¢ ¢ ¡ ¡ ¡ ¡ £ £ £ ¡ ¡ ¡     ¡   ¡ ¡    ¡ ¡ ¡ ¡ ¡ £ ¥ ¢ ¢ ¥ ¡ ¡ ¡ ¡ ¡ £ ¢ ¥ ¥ ¢ ¡ ¡ ¡ ¡ ¡ £ ¥ ¢ ¢ ¥  ¨    ¨    ¨   ¥ ¡ ¡ ¡     ¡   (60) ¡ ¢ £ ¡ ¢ ¤               ¡ £ ¡ £ £ ¡ ¢ £ ¡ ¢ £ ¡ ¢ ¡ ¡ ¡ ¡ £ £ ¡ ¡ . On the other hand. . .ula. derivatives in the physical ( .cecalc. .

ula. ) generalized coordinates this equation takes ¢ £       ¡   §   ¡ ¥ ¡   ¡ 121 Sergio Rojas: http://www. ) physical coordinates has the form: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¢ ¤ ¤ ¤ ¥ ¢ ¥ ¢ ¥ ¤ ¡ ¤ ¡ ¤  ¢ ¢ £ ¢ £ ¡ £ ¢ ¥ £ ¤ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¥ ¥ ¥ ¢ ¡ £ ¢ £ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ £ £ ¢ ¥ £ ¤ ¡ ¡ ¡ ¦ £ ¡ ¡ ¡ ¦ £ ¡ ¡ ¡ ¦ ¥ ¢ ¥ ¢ ¥   ¥   (62) In two dimensional ( .ve/ sergio/ ¡ . For example.cecalc. Laplace’s equation in two dimensional ( .An Introduction to Computational Fluid Dynamics ¡ ¡ ¡             ¡ ¢ ¢ ¢ ¢ £ ¢ £ ¡ £ ¢ ¥ £ ¤ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ (61) Complications introduced by the use of generalized coordinates include to find the form of the governing equations in the generalized coordinates.

) generalized coordinates are orthogonal. which means ¢ £ ¡ ¡         ¡ ¡ ¡ ¡ ¡ ¡   ¡ ¡          § § ¡ ¢ £ £ £ ¡ ¡ ¡ ¡   ¢     ¢   ¡ ¡ ¡ ¡ ¡ ¥ ¡     ¥ ¡    ¡ ¡                ¡ ¡   ¡ ¡   ¡ ¡ ¢ £ £ ¢ ¡  ¡ ¡   £ ¤ £ ¤   ¥ ¡ ¡    ¢ ¥ ¦ §   £ ¤ £ ¤ ¡ ¢ ¢ ¡ ¡     £ ¤   £ ¤   £ ¤     ¥     ¢ ¢ ¢ £     ¥ ¥ 122 Sergio Rojas: http://www.ula.ve/ sergio/ ¡ .An Introduction to Computational Fluid Dynamics the form: (63)         where (64a) (64b) (64c)  £ ¤   In case the ( .cecalc.

ula. . ) physical coordinates and the ( . then equation 63 becomes: (65)                 if in addition the transformation is conformal. ) physical coordinates. .An Introduction to Computational Fluid Dynamics and ¡ . then the and ) applies given Cauchy-Riemann conditions ( and equation 65 becomes: ¡ ¡ ¢ ¢ ¡ ¡ £ £   ¡ ¡       ¡ ¡ ¡   ¡ ¡     ¡ ¡ ¡ ¡     ¡ ¡   § ¡ ¢   £ £   ¢ ¡     ¡ ¡ ¡ ¡ ¡ ¡    ¡ ¡ ¡ ¡ ¢ ¢ ¤ ¤  which is an equation structurally no more complex than the one in ( . .ve/ sergio/ ¡ . and so on. . the transformation parameters . ) curvilinear coordinates is not available. equation 62.cecalc. When an analytical mapping between the ( . must be computed         ¡ ¡ (66)           ¡    §   § ¡ ¢ £ £ £ ¢ ¢ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¥     ¥   ¡ ¢ ¤ £ ¡ ¢ ¢ ¡ ¡ £ ¡ ¢ ¤ ¢ ¡ ¡ 123 Sergio Rojas: http://www.

For instance. if working with a centered finite discretization scheme.ula. in 2D one could have: 124 Sergio Rojas: http://www. usually using the same discretization scheme as the one used to discretize the derivative terms in the governing equations. the former are discretized using the same corresponding formulae.ve/ sergio/ ¡ . if the latter are discretized using a finite difference scheme. That is.cecalc.An Introduction to Computational Fluid Dynamics numerically.

) domain.ula. ¢ £ ¥ ¡ ¢     ¡ ¢       ¤   ¤ ¤ ¤       £ ¡ ¡ ¡ ¡ £ ¦     ¦ ¦ ¦                 ¡ ¢ ¢ ¢ £ £ £ ¢ ¢ ¡   ¤ ¤ ¤ ¤       £ ¡ ¡ ¡ ¡ £ ¦ ¦ ¦ ¦ (67)    ¥ § ¥ ¥ ¥ ¥ ¡ ¢ ¢ ¢ ¢     ¤ ¤ ¤ ¤               £ ¡ ¡ ¡ ¡ £ £ £ ¦   ¦ ¦ ¦       ¢ ¢   ¡ ¢ £ ¢ £ £ ¢ ¤   ¡ ¤ §   § £ ¤ £    ¤    £ 125 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics   ¥ ¥ recall that the governing equations are discretized in the ( .ve/ sergio/ ¡ .cecalc.

¡ ¡ ¢ ¤ ¢ ¡ ¡ £ 6.) are then obtained by means of relations 60.ula. . obtaining for the continuity ¢ £ 126 Sergio Rojas: http://www. 2.ve/ sergio/ ¡ . pages 64-69 gives general formulae for transforming first and second two dimensional general partial differential equations to generalized ( . ) coordinates. He then goes on and applies the formulae to fluid flow equations. on page 119.cecalc.An Introduction to Computational Fluid Dynamics which usually corresponds to a uniform rectangular grid. the Continuity Equation Fletcher. vol.1 On fluid flow equations expressed in generalized coordinates Assuming the grid in the physical domain does not change with time. etc. The inverse parameters ( .

An Introduction to Computational Fluid Dynamics equation in generalized coordinates: (68a) (68b) ¡   ¤   ¢ ¡     § §   ¡ ¡     ¡ while for the x-momentum equation of incompressible viscous flow.ula.ve/ sergio/ ¡ . expressed in nondimensional form. he obtains: (69a) (69b) ¤ £ §   ¦¡ ¡ ¡   ¡ ¦¡ ¡ ¡ ¢ £       ¡ ¢ ¢ £ £ ¡ ¡ ¡    £     ¢  £   ¤ §   § ¥ ¡     ¥ ¡ ¡ ¡ ¤    ¢     ¤ ¤ ¤ ¤ ¤ ¥ ¤ ¡ ¤ £ ¡  § ¡ ¡ ¡ ¡ ¢ £ £ £ ¢ ¢ ¡¤ § § ¡ ¡ ¢ ¢ ¡ ¡ ¡   ¡ ¡ § ¡   ¡ £ ¡ ¢ ¡ ¢ ¡ ¤ ¤   £ ¤ ¡  ¢  £ ¤ £ §  §       ¡ ¥ ¡   £ ¦ 127 Sergio Rojas: http://www.cecalc.

In the case of high flow problems.ve/ sergio/ ¡     ¤ ¤ ¤ ¤ ¢ ¢ ¤ ¡ ¢ ¡ ¡   .An Introduction to Computational Fluid Dynamics ¡ ¡ ¡ ¡ ¡ ¡  ¢ ¢  ¤ ¤ § ¡   § ¡ ¡ ¨  ¨  ¢ ¢ ¡ £ ¡ ¡ ¡ in and in the last set of equations Let’s mention that terms like could introduce an error if significant grid stretching is permitted.ula. ¡ ¡ ¤ ¤ ¤   ¢ £ ¤ £ ¡   £ £ £ 128 ¤ §    ¡     § ¥ ¡     (69c) ¡ ¡ ¦ £ ¡ ¡ ¡ ¡   ¢ ¤ ¤ ¤ ¤ ¢ (69d) § ¨  ¨  § ¢ ¢ ¢ ¡ ¡ ¡ ¡ ¡ ¡ ¤ ¥ ¤ £ £ £  ¡    £   £ Sergio Rojas: http://www. The implementation of generalized finite difference schemes is not more difficult than the implementation of the finite volume method and produces solutions of comparable accuracy. leading to a reduction in the accuracy of the computed solution.cecalc. this terms does not usually have a large effect. however.

so you can go ahead and start a carefully reading of many of good sources on CFD. However. or even better increase.ula.cecalc. In there you will find precise pointers to the various tools available to assist you with the numerical solution of a wide range of mathematical problems. I do not expect to have covered the expectations you may have had about the impressive and growing subject of Computational Fluid Dynamics in this short course. it is my hope to have keep.ve/ sergio/ ¡ . These tools are widely available on nearly all computer platforms. 129 Sergio Rojas: http://www. a few of them are included in the reference section.An Introduction to Computational Fluid Dynamics 7 Closure Let me first thanks very much to any one of you for being a participant of this Workshop. your motivation on this wonderful field.

eng.4. I am listing here some online resources that could be helpful in going further in the study of Computational Fluid Dynamics: CFD-ONLINE: http://www.ve/ sergio/ ¡ .ula.cecalc.cfdonline.html http://people.1 On-line general references In addition to the references listed at the end of this document and to the online CFD examples listed on section 2.html         130 Sergio Rojas: http://www.An Introduction to Computational Fluid Dynamics 7.uk/staff/cts/cfdbook/ http://www.crs4.com/ Online CFD Books: http://www.de/ bds/numerics/cfdlectures.rzg.mpg.warwick.ac.1.nas.it/HTML/int book/NumericalMethods/int book.nasa.html http://www.gov/ pulliam/mypapers/vki notes/vki notes.

M. Computational Methods for Fluid Dynamics. ftp://ftp.tudelft.An Introduction to Computational Fluid Dynamics Grid Generation: http://gid.html Ferziger.de/pub/technik/peric/ Pozrikidis. J.cecalc.ucsd. H.informatik.html Books with web sites: Wesseling. & Peric. Springer.univ.it/ nirftc/research/easymesh/easymesh.nl/nw/users/wesseling/cfdbook.rwth-aachen. Introduction to Theoretical and Computational Fluid Dynamics.html         http://wwwdinma. http://dutita0. (2000). Springer.springer. http://stokes.univ.es/ http://www-users. Principles of Computational Fluid Dynamics. C.de/ roberts/meshgeneration.upc.twi. Oxford.edu/pozrikidis/TCFD/ 131 Sergio Rojas: http://www.cimne.ula.ve/ sergio/ ¡   .html http://www-dinma. P. (1999). (1997).it/ nirftc/research/easymesh/easymesh.trieste.trieste.

Introduction to the finite element method. Press.An Introduction to Computational Fluid Dynamics References [1] Batchelor. (1967). Prentice Hall. [5] Ottosen. Computational techniques for fluid dynamics. C. vol. K. [6] Press. S. 2nd ed. C. An introduction to the finite element method. (1994). V. Wiley. V. An introduction to fluid dynamics. Tensor analysis: Theory and applications to geometry and mechanics of continua. S. Numerical solutions for partial differential equations. (1991). E.ve/ sergio/ ¡ . N. H. & Vorozhtsov. W. [8] Sokolnikoff. CRC Press. Springer-Verlag. & Wheatley . 1 & 2. N. Cambridge Univ..ula. Cambridge University Press.. [7] Reddy. F.cecalc. [3] Ganzha. J. H.. (1964). (1984). et al. & Peterson. [4] Gerald. Applied numerical analysis. McGraw-Hill. A. P. 132 Sergio Rojas: http://www. [2] Fletcher. Wesley. (1992). (1992). J. Numerical recipes in fortran. I. 2nd ed. G. 5th ed. G. (1996). O.

ve/ sergio/ ¡ . 133 Sergio Rojas: http://www. The finite element method. (1989). C. O.ula. 1 & 2. 4th ed.cecalc. R. L.. & Taylor. vol. McGraw-Hill.An Introduction to Computational Fluid Dynamics [9] Zienkiewicz.

Sign up to vote on this title
UsefulNot useful