Professional Documents
Culture Documents
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/
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 uid ow . . . . . . . . . . . . . . . . . . uid ow . . . . . . . . . . . . . . . . . .
6 6 8 8 9 9 10 11 11 14
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
3 Some aspects of numerical computations 4 Finite Difference Approximation of Differential Equations 4.1 4.2
3
4.3
58 64 64 66 68 69 71 72 77 82 82 83
5 Finite Element Method (FEM) 5.1 5.2 5.3 Intuitive introduction: the area of a circle . . . . . . . . . . Generalities . . . . . . . . . . . . . . . . . . . . . . . . . . Steps of the FEM: a one dimensional model problem . . . . 5.3.1 5.3.2 Formulating the weak form of the problem . . . . . Choosing approximating functions for the unknown 5.3.2.1 5.3.2.2 5.3.2.3 5.3.3 5.4
4
One dimensional lineal elements . . . . . One dimensional quadratic elements . . . One dimensional higher order elements . .
5.5
94 114
7 Closure 7.1
References
1
1.1
A main characteristic that differentiate a uid from a solid in that the former can not withstand any attempt to change its shape when at rest. That is, uids at rest can not sustain a shear force. If the uid is in motion, however, it can not only sustain a shear force, but it can also transmit such force. Based on the continuum hypothesis which considers that the physical properties characterizing the state of a uid such as pressure, density, velocity, etc. vary continuously, equations describing the motion of uids can be derived without regarding the behavior of individual molecules (Batchelor 1987; Sherman 1990). Nevertheless, derivations of similar equations based on more fundamental ideas coming from physics can also be obtained (Huan 1987; Chouduri 1998). The later approach is a necessary step to put on better grounds the results obtained under the assumptions of the continuum hypothesis, and, more importantly, it is the road to be follow in situations where the continuum hypothesis assumptions can not be fullled, as for example for ows at very low density.
7 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
1.2
(1)
1.3
(2)
1.4
When dealing with the numerical solution of equations 1, two dimensionless form are commonly encounter in the literature, both , including a dimensionless parameter, the Reynolds number that is used to characterize the ow regimes (Bachelor 1967, Tritton 1992):
1.4.1 Low
uid ow
(3)
1.4.2 High
uid ow
As a way of referring to the challenge and difculties that the question of global existence and uniqueness of the solution of the Navier Stokes still represent, let me just mention that this problem was declared, in year 2000, to be one of the seven greatest open problems in mathematics at the Clay Mathematics Institute of Cambridge, Massachusetts (http://www.claymath.org/Millennium Prize Problems/). Finally, lets mention that a complete description of a uid ow problem could involve the coupling with other equations like energy conservation (i.e. heat transfer) or auxiliary (phenomenological or constitutive) equations describing the physics of the ow phenomenon under consideration.
10 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
(4)
2
2.1
11
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
13
2.2
Importance of CFD
Lets rst 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 ow 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 ow 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 understand behavior of various type of ows 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 uids. The results obtained from a CFD simulation can be used to analyze existing designs (.i.e. 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. The ability to simulate ideal conditions is important for understanding the theory behind the model being described. To write good quality CFD code will take some time and a lot of intellectual resources. Nevertheless, it is worthwhile to spend some time on understanding the main aspects of CFD, even when one plans
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
15
to use somebody else code to perform our own research or to develop a better understanding on the phenomena of uid ow. Being familiar with the principles of CFD will allow us to comprehend much better the computational results obtained through numerical simulation.
2.3
Once the mathematical model is obtained and the equations discretized according to the numerical methodology (nite difference, nite elements, nite volume, etc.) and coded in a computer program (i.e. FLUENT, FIDAP, FEATFLOW, CFDRC, etc), usually a CFD simulation involves three basic step: 2.3.1 Pre-Processing Basically, in this step the performer of a CFD simulation set up the physical parameters dening the uid(s) and material(s) properties
16 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
involved in the simulation to be carried out. 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. Essentially, 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. 2.3.2 Processing At this level of the CFD simulation, the user usually can write custom User Dened Functions and Subroutines to incorporate special functionality (.i.e. 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.
17
2.3.3 Post-Processing In the steps the analysis of the obtained numerical results is carried out, and the user decide whether a new execution of the simulation is required. The results are often presented graphically to assist in visualizing whats happening in the ow domain. 2.3.4 Problems of a CFD simulation Computer simulations are far from being the panacea of all our computational problems. Lets just mention a few problems that one could face whenever doing CFD: Numerical solution may experience instabilities and divergence. Solution, if possible, may be very expensive. Problems with multiple solutions (non-linearities are present) are hard to deal with.
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
18
The mathematical model may not be adequate to properly describe the physical situation being simulated. Real experiments are necessary to fully be condent of the numerical results.
Research in computational methods are devoted to nding better and reliable ways to diminishing these and other disadvantages of CFD. Moreover, the role of CFD has become so strong that it can be considered as a third area of uid dynamics. The other two classical elds are experimental and theoretical uid dynamics.
19
2.4
20
21
22
23
2.4.1 Online CFD sample results Many other examples can be found on the Internet. Some sites are: From Physics of Fluids Journal: http://ojps.aip.org/phf/gallery/index1.jsp From CFD and thermal analysis archive: http://www.itsc.com/movies/ Some FEATFLOW CFD results: http://www.featow.de/album/ Pictures from the book An Album of Fluid Motion by Milton Van Dyke, 1982: http://www.owlnet.rice.edu/ mech372/album/ Gallery of Fluid Dynamics: http://www.eng.vt.edu/uids/msc/gallery/gall.htm Other: http://www.eng.vt.edu/uids/msc/gallery/conden/conden.htm
Some of this sites show pictures of real uid behaviour; others are obtained via CFD simulations.
24 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
At CeCalCULA (http://www.cecalc.ula.ve/) we have available FLUENT and CFRC, two well known CFD software packages, to perform uid dynamics simulations. We are in process of getting involved on a research project to study ow of blood in thin capillaries.
25
26
Experience and mathematical demonstrations show that to obtain high accuracy in a computed numerical solution the grid should be orthogonal or near orthogonal. This, however, implies relatively simple boundary shapes for the computational domain and some restrictions on the disposition of the grid points. In fact, the use of generalized coordinates introduces additional terms in the truncation error if the grid is not orthogonal. Nevertheless, departures from orthogonality of can be tolerated. 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. Establishing convergence directly is in general a very difcult matter. Indirectly routes to explore the convergence of a numerical scheme have been devised. One criterion is that:
27
Consistency
Stability
Convergence
Consistency: implies that the discretization scheme can be reverse to obtain the governing equation(s). Stability: has to do with the algorithm applied to solve the discretized equations. It must be stable. That is, errors do not grow as the as the computation of the solution progress. Lax Equivalence Theorem (time dependent problems): Given a properly posed linear initial value problem and a discretization scheme to it that satises the consistency condition, stability is the necessary and sufcient condition for convergence. From the truncation errors analysis, it is expected to obtain a more accurate solution as the grid size of the computational domain ). becomes smaller (
28
To achieve a level of accuracy, sometimes computational efciency requires to solve a higher-order discretization scheme on a coarse grid than a low-order scheme on a ner grid. There are circumstances on which one is only concerned in obtaining a computational solution close to the true solution at some level of accuracy, without worrying about the convergence of the approximation scheme (example are some no convergent series that are commonly use to nd numerical values of some functions, like for instance the error function).
29
4.1
Taylor expansion of
around
:
PSfrag replacements
(7)
around , and
(8)
An Introduction to Computational Fluid Dynamics
are:
32
(9)
(10)
33
(11)
in the case of having a uniform grid, , equations 10 and 11 yields what is called centered nite difference discretization schemes for rst and second order derivatives and having a second order truncation error:
34
(12a)
(12b)
one obtains:
which can be rewritten in the form: (13a) (13b) (13c) (13d) (13e)
35
where and similarly with , , and . Inspection of this equation shows that its evaluation at nodes and introduces two , which can be eliminated by use of the extra unknowns, and boundaries conditions (equations 6a and 6b on page 30) discretized with the and nite difference approximation 12a. Noting that correspond to nodes at which and respectively, the substitution of equation 12a on the boundary conditions, equations 6, and taking the rst ) and last ( ) equations from equation 13 one obtains: (
36
After combining this equations one nally gets the full centered nite 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 efciency is an issue, one will need to use sophisticated algorithms that make use of the structure of the matrix to nd the numerical solution of
(15c)
37
such algebraic system of equation very efciently 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)
efcient mathematical algorithms have been devised to nd numerical solutions of systems of equations leading to tridiagonal matrices. In
38 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
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:
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 Scientic Subroutine LIbrary (ESSL and PESSL) to perform numerical computations,
39 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
4.2
A solved example
Lets apply the theoretical ideas presented in the previous section to nd the numerical solution of (compare with equation 5, on page 30): on
with:
(18a)
40
The listing of a Fortran code implementing the solution of this problem, based on the ideas presented in the previous section, is given below. For illustrative purposes it makes use of a subroutine that was written to nd numerical solutions of systems of equations leading to banded tridiagonal matrices (the tridiagonal solver can be found in reference [6]).
#--------# Makefile #--------COMPILER = pgf90 41 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
SOURCE_FILES = main.f90 \ myFunc/matrix_A.f90 \ myFunc/Eq_rhs_T.f90 \ myFunc/First_Der_Coef_R.f90 \ myFunc/Func_Coef_S.f90 \ NR/tridag.f OBJECTS = main.o \ matrix_A.o \ Eq_rhs_T.o \ First_Der_Coef_R.o \ Func_Coef_S.o \ tridag.o LIBS= FLAGS = #---# NOTE: you must make the white space just before the $(COMPILER) # instruction by hitting the computer TAB keyword. #---exec_file: $(OBJECTS) $(COMPILER) $(FLAGS) $(OBJECTS) -o exec_file $(LIBS) main.o: main.f90
42
$(COMPILER) $(FLAGS) -c main.f90 $(LIBS) matrix_A.o: myFunc/matrix_A.f90 $(COMPILER) $(FLAGS) -c myFunc/matrix_A.f90 $(LIBS) Eq_rhs_T.o: myFunc/Eq_rhs_T.f90 $(COMPILER) $(FLAGS) -c myFunc/Eq_rhs_T.f90 $(LIBS) First_Der_Coef_R.o: myFunc/First_Der_Coef_R.f90 $(COMPILER) $(FLAGS) -c myFunc/First_Der_Coef_R.f90 $(LIBS) Func_Coef_S.o: myFunc/Func_Coef_S.f90 $(COMPILER) $(FLAGS) -c myFunc/Func_Coef_S.f90 $(LIBS) tridag.o: NR/tridag.f $(COMPILER) $(FLAGS) -c NR/tridag.f $(LIBS) mclean: rm -rf $(OBJECTS) file.out mrun: exec_file !--------
43
!main.f90 !-------PROGRAM FINITE_DIFFERENCE_1D IMPLICIT NONE INTEGER N, AllocateStatus, i, j DOUBLE PRECISION, ALLOCATABLE :: AA(:,:) DOUBLE PRECISION, ALLOCATABLE :: copyAA(:,:), copyRHS(:) DOUBLE PRECISION, ALLOCATABLE :: A(:), B(:), C(:), RHS(:), U(:) DOUBLE PRECISION, ALLOCATABLE :: copyA(:), copyB(:), copyC(:), copyR(:) DOUBLE PRECISION :: Xa, Xb, alpha1, beta1, gamma1, alpha2, beta2, gamma2 DOUBLE PRECISION :: K, X, Sol, H CHARACTER*20 FNAME DOUBLE PRECISION :: PI PI = 4.0D0 * ATAN(1.0D0)
write(*, (5X,A), ADVANCE=NO) How many nodes?: READ (*,*) N ALLOCATE (AA(N,N), STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** "
44
ALLOCATE (copyAA(N,N),copyRHS(N), STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " ALLOCATE (A(N),B(N),C(N),RHS(N),U(N), STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " ALLOCATE (copyA(N),copyB(N),copyC(N),copyR(N), STAT = AllocateStatus) IF (AllocateStatus /= 0) STOP " *** NOT ENOUGH MEMORY *** " Xa = 0.0D0 xb = -1.0D0 DO WHILE( Xa .GE. Xb ) write(*,(5X,A),ADVANCE=NO) Enter left(Xa) and right(Xb) boundaries: READ (*,*) Xa, Xb END DO !----! write(*,(5X,A),ADVANCE=NO) Enter alpha1, beta1, and gamma1: ! READ (*,*) alpha1, beta1, gamma1 ! write(*,(5X,A),ADVANCE=NO) Enter alpha2, beta2, and gamma2: ! READ (*,*) alpha2, beta2, gamma2 !-----
45
= = = = = =
CALL get_matrix_A(AA,RHS,A,B,C,N,Xa,Xb,alpha1,beta1,gamma1, & alpha2,beta2,gamma2) !saving a copy of A copyAA(1:n,1:n)=AA(1:n,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,N ! write (*,20) (AA(i,j), j=1,N) ! end do
! DO i=1,N
46
CALL TRIDAG(A,B,C,RHS,U,N) open(10,file="file.out") write (10,18) write (10,19) h = (Xb-Xa)/(N-1) !DO i=1,N DO i=2,N-1 X = DBLE((i-1))*h + Xa !write (*,22) (U(i) - Sol(X)) write (10,23) x, U(i), Sol(X), abs((U(i) - Sol(X))/Sol(X))*100.0d0 !write (10,23) x, U(i), Sol(X), abs((U(i) - Sol(X))/U(i))*100.0d0 end do close(10) 18 format(#,9x, x ,11x,numSol,7x,exactSol,8x,abs(diff)) 19 format(#,9x,---,11x,------,7x,--------,8x,---------) 20 format(6F10.4) 22 format(F16.6)
47
23 format(4F15.6) print *, \t\t **** Calling Gnuplot ***** call system("gnuplot < myplot.gnu") DEALLOCATE (A) END PROGRAM FINITE_DIFFERENCE_1D !---------------------------Double Precision FUNCTION SOL(X) IMPLICIT NONE DOUBLE PRECISION X DOUBLE PRECISION PI PI = 4.0D0 * ATAN(1.0D0) SOL = SIN(2.0d0*PI*X) return end !----------------------------
48
Double Precision FUNCTION K(X) IMPLICIT NONE DOUBLE PRECISION X K = 1.0d0 + X*X*X*X return end !-----------!matrix_A.f90 !-----------SUBROUTINE GET_MATRIX_A(AA,RHS,A1,B1,C1,N,Xa,Xb,alpha1,beta1,gamma1,& alphaN,betaN,gammaN) IMPLICIT NONE INTEGER N, I, J DOUBLE PRECISION :: AA(N,N), RHS(N), A1(N), B1(N), C1(N), Xa, Xb DOUBLE PRECISION :: alpha1, beta1, gamma1, alphaN, betaN, gammaN DOUBLE PRECISION :: X, h, h2, A, B, C, D external A, B, C, D double precision pi pi = 4.0D0 * ATAN(1.0D0)
49
h = (Xb - Xa) /(DBLE(N)-1.0D0) h2 = 2.0D0*h AA = 0.0D0 AA(1,1) = (alpha1/h2)*B(Xa,h) + beta1*A(Xa,h) AA(1,2) = (alpha1/h2)*(A(Xa,h) + C(Xa,h)) RHS(1) = (alpha1/h2)*D(Xa) + A(Xa,h)*gamma1 A1(1) = 0.0d0 B1(1) = AA(1,1) C1(1) = AA(1,2) x = Xa + h DO I = 2, N - 1 AA(I,I-1)= A(X,h) AA(I,I)=B(X,h) AA(I,I+1)=C(X,h) RHS(I) = D(X) A1(I) = AA(I,I-1) B1(I) = AA(I,I) C1(I) = AA(I,I+1) x = x + h 50 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
END DO AA(N, N - 1)= (alphaN/h2)*(A(Xb,h) + C(Xb,h)) AA(N,N)= (alphaN/h2)*B(Xb,h) - betaN*C(Xb,h) RHS(N)= (alphaN/h2)*D(Xb) - gammaN*C(Xb,h) A1(N) = AA(N, N - 1) B1(N) = AA(N, N ) C1(N) = 0.0d0 END SUBROUTINE GET_MATRIX_A Double Precision FUNCTION A(X,h) IMPLICIT NONE DOUBLE PRECISION X, h, R External R A = 1.0d0/(h*h) - R(X)/(2.d0*h) return end Double Precision FUNCTION B(X,h)
51
IMPLICIT NONE DOUBLE PRECISION X, h, S External S B = -2.0d0/(h*h) - S(X)/(2.d0*h) return end Double Precision FUNCTION C(X,h) IMPLICIT NONE DOUBLE PRECISION X, h, R External R C = 1.0d0/(h*h) + R(X)/(2.d0*h) return end Double Precision FUNCTION D(X) IMPLICIT NONE DOUBLE PRECISION X, T External T
52
D = T(X) return end !----------!Eq_rhs_T.f90 !----------! ! u + R(x)*u + S(x)*u = T(x) ! ! Right Hand Side of equation. ! Double Precision FUNCTION T(X) IMPLICIT NONE DOUBLE PRECISION X DOUBLE PRECISION :: a, b, PI PI = 4.0D0 * ATAN(1.0D0) b = 1.0d0 + X*X*X*X a = -8.0d0*PI*X*X*X*COS(2.0d0*PI*X) + 4.0d0*PI*PI*B*SIN(2.0d0*PI*X)
53
T = - a/b return end !-------------------!First_Der_Coef_R.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)/(1.0d0 + X*X*X*X) return end !---------------
54
!Func_Coef_S.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, D ! K = 0.2d0 ! D = 2.0d0 S = 0.0d0 ! -K/D; return end
55
c-------SUBROUTINE TRIDAG(A, B, C, R, U, N) IMPLICIT NONE INTEGER N, NMAx DOUBLE PRECISION A(N), B(N), C(N), R(N), U(N) PARAMETER (NMAx=5000) INTEGER j DOUBLE PRECISION bet, gam(NMAx) IF (B(1).EQ.0.) THEN STOP tridag: rewrite equations END IF bet = B(1) U(1) = R(1)/bet DO j = 2, N gam(j) = C(j-1)/bet bet = B(j) - A(j)*gam(j) IF (bet.EQ.0.) THEN STOP tridag failed END IF U(j) = (R(j)-A(j)*U(j-1))/bet END DO DO j = N - 1, 1, -1 U(j) = U(j) - gam(j+1)*U(j+1) END DO 56 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
RETURN END
#----------# myplot.gnu #----------# # excelent gnuplot site: # http://art.aees.kyushu-u.ac.jp/members/kawano/gnuplot/index-e.html #---# If this does not want to work, take out \ and joint the # lines in one long line #-----------set xlabel "x" set ylabel "y" set title "Finite Difference" plot "file.out" using 1:2 title "Numerical Sol." with lines, \ "file.out" using 1:3 title "Exact Sol." with lines, \ "file.out" using 1:2:4 notitle with yerrorbars !echo "waiting 15 seconds to continue" pause 15
57
4.3
A wide variety of physical and engineering problems are posed in terms of second order partial differential equations, being an archetypical example the Poisson equation: (19)
which satisfy equation 19 Usually one would like to nd a function region of interest subject to some desired behavior on within some the boundary of the region of interest (boundary conditions). 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 classication of partial differential equations from a computational point of view. The standard classication of such problems as hyperbolic, parabolic or elliptic is less important because the character of
58
them could, as usually happen, change during computation. Nevertheless, there may be situations where a problem will remains of a particular type during the whole computation. In such cases, one should take advantage of the computational techniques developed for that particular case. Finite difference discretizations have also been developed to nd numerical solution of two (and higher) dimensional boundary value problems, by adapting the equations obtained in the one dimensional case to handle the respective higher dimensional case. In the case of of 2D partial differential equations, approximations of relevant derivatives in uniform grids are
59
being the generalized (also called logical) computational domain a rectangular grid:
60
. . .
as: (21a)
63
5
5.1
64
A few words are in order: The domain of interest can be discretized, depending of its shape, into a mesh of only one type of elements or into one of more than one type of elements. In general, 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, each kind should be isolated and its properties developed. Sources of error can be attributed to: errors due to the approximation of the domain; errors due to the approximation of the solution; error due to numerical computation. 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 nite element solution depends on the element used and the problem being solved.
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
65
5.2
Generalities
FEM are casted into the broad class of numerical methods known as weighted residual methods, 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 coefcients, and are known conditions; analytic functions, often referred to as trial functions. For time-dependent problems, a system of ordinary differential equations will be solved for . For steady problems a system of . algebraic equations will be solved to nd the A conceptual difference emerges here from the nite difference
66 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
methodology, where solution is found at nodal (discrete) points. On a are found, solution is known weighted residual method, once the everywhere in the computational domain. The coefcients
Where is the residual obtained after substituting equation 24 into the differential equation being solved. By this means, a set of equations for are generated allowing theirs determination. Different choices the denes the particular type of for the weight (test) function weighted residual method being used. 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
5.3
Lets consider the problem of nding numerical solution of (compare with problem 5, on page 30): on
As we know this differential equation governs one dimensional steady heat ow as well as other important physical and engineering phenomena like diffusion, elastic bars, laminar (Poiseuille) ow in a pipe, etc. The set of equations 26 is known as the strong formulation of one dimensional heat ow.
68 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
(26)
5.3.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), 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
which is known as the weak (integral or variational) form of the one dimensional steady heat equation. The nite 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). Also, the order of differentiation of the unknown(s) is lower in the weak form ( needs to be differentiable once) than in the strong form.
(29)
70
As we have been talking about, FEM approach involves the splitting into smaller parts (nite elements) the region of interest for which one can establish an approximation for the unknown s, given in this way an elementwise approximation of the unknown function. 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. The approximation must be able to represent an arbitrary constant value of the function being approximated. The approximation of the function over element boundaries must be continuous. There are situations on which this requirement is not fullled (Zienkiewicz and Taylor, 1989). In many situations, an expansion of the unknown in terms of a
Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
71
i,j
An Introduction to Computational Fluid Dynamics
polynomial expansion is used for the elementwise approximation. 5.3.2.1 One dimensional lineal elements
The one dimensional domain [ , ] is divided into lineal elements. Consider the element with end points at and . The unknown is
72
and are known as the element shape In this formulation, functions of element ( ). The representation of the unknown , given by equation 30a, separates the inuence of geometry via the element shape function from the inuence of physics given by the nodal temperatures , . This means that once the geometry of the element is known, the element shape function can be established directly. Equation 30a approximates the
73
function as an interpolation, dened by the element shape functions, between the function nodal values. Now, a global shape function is dened in such a way that one global shape function is associated to each nodal point:
74
if
in element 1
otherwise
otherwise if in element 3
otherwise
75
Now one can express the approximation of the function global shape functions:
(33)
76
5.3.2.2
Higher order elements can be easily constructed. In this case, the approximation of the unknown will contain terms of higher order than the linear ones. Quadratic elements are constructed with three nodes by
77
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, the unknown is represented in the form:
notice that
78
As before, , , and are the element shape functions of element ( ). Also, global shape functions are dened in such a way that one global shape function is associated to each nodal point:
79
if
in element 1
otherwise if in element 1
otherwise if in element 2
otherwise if in element 2
otherwise
80
Now one can express the approximation of the function global shape functions:
(37)
81
5.3.2.3
Higher order elements can be introduced by properly numbering the nodes of the element. The element shape function is obtained from the Lagranges interpolation formula:
(38)
5.3.3 Choice of the weight function When nding the weak form formulation of the problem at hand (see equation 29, on page 69), an arbitrary weight function is introduced to get equation 29 and that needs to be determined. A suitable choice of this weight function is obtained by the Galerkin method which (see end of
82
section 5.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, on page 67). Loosely speaking, the Galerkin method is expressed by saying that weight function = trial function
5.4
As we have seen, the basic steps in the nite element formulation we are using involves three step: Find the weak formulation of the problem. For our model problem 26,
83
Make an elementwise approximation over the entire domain of the unknown function, such as: (40)
(39)
(see equations 32 and 36 on pages 76 and 81 respectively). Choose the weight function according to the Galerkin method: (41)
84
So, to continue with the development of equation 39, well consider the following:
. . .
is an arbitrary scalar function ( ), the matrix is Since arbitrary. Inserting equation 42 into equation 39, and using the fact that
(42)
85
(43)
is independent of x, we obtain:
or
86
(44)
which is the required nite element formulation. This expression could be written in the more compact familiar form:
(45)
87
(46)
Lets note that the symmetry of K is a consequence of the Galerkin method. This fact, 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. Lets write
88 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
(47) (48)
(49)
(50)
. . .
. . .
. . .
89
(51)
(52)
. . .
90
. . .
. . .
where we have made use of the shape function properties (see equations 34e and 35, on pages 78 and 79 respectively): at nodal point i otherwise ; if in element 1
to continue, now one can make use of the boundary condition of our model problem (equation 26, on page 68), from which we obtain: (53a) (53b)
otherwise
91
(54)
and
. . .
Last, for
we obtain,
. . .
92
. . .
(55)
Now, denoting the elements of matrix by , equation 46, using equations 51, 54, and 55, can be written in the form:
!
. . .
. . .
!
. . .
. . .
93
. . .
(56)
. . .
5.5
By using the ideas of the previous section, lets nd the numerical solution of the one dimensional problem: on
with: (57a)
94
(57b)
95
(*-------------------------*) (* PREAMBLE *) (* -------*) RegularForm[x_]:= OutputForm[NumberForm[TableForm[x//N], ExponentFunction-> (If[-1<#<1, Null, #]&), NumberFormat->(If[#3=="", SequenceForm[#1, #3], SequenceForm[#1, "E", #3]]&)]] ; (* -------*) Needs["GraphicsLegend"]; (* -------*) FESavingPlot = Directory[]; (* -------*) (* MySave[name_, plot_] := Display[name,plot]; *) MySave[name_, plot_] := Display[StringJoin["!./psfix_3.0 > ",name],plot]; (* -------*) MySavingPlot[name_, plot_] := Module[{guardar, oldDir}, Clear[guardar]; guardar = Input["\t\t\t Hit 1 + ENTER to save, otherthing to continue "]; If[guardar == 1, oldDir = Directory[]; SetDirectory[FESavingPlot]; MySave[name, plot]; SetDirectory[oldDir] ](* close if *)](* close Module *);
96
(* -----------*) (* END PREAMBLE *) (* -----------*) (******************************************* Piece wise functions are best defined using Which[] because the derivative operator D[] knows how to deal with Which[] properly. ********************************************) Clear[Xa, Xb, MainNodes, InternalNodes, TotalNodes, X, x, xx, Nlocal, i, j, f, jj, nglobal, Nglobal, Dlocal, Dglobal, Klocal, MatrixLocal, K1, Kglobal]; Xa = 0.0; Xb = 1.0; MainNodes = Input["How many MAIN (global) nodes (elements = Nnodes-1)? "]; InternalNodes = Input["How many INTERNAL nodes (order of the element)? "]; (*-------------------------------------------------------------------Global nodes are designed by X[i]. INTERNAL nodes by xx[i][j], with [i] representing the node and [j] representing the element. An example of 3 GLOBAL nodes [*] (defining 2 elements) with each element having 2 INTERNAL nodes (.) can be represented as: *----.---.---*---.---.---*
97
Global elements have same length = (Xb - Xa)/(MainNodes - 1) Internal nodes define internal elements of same length = (X[j+1] - X[j])/(InternalNodes + 1) ---------------------------------------------------------------------*) X[1] = Xa; X[i_] := X[i-1] + (Xb - Xa)/(MainNodes - 1); (** *** Here [i] can go from ONE, xx[1][j] = X[j], to (InternalNodes + 2) *** for which xx[InternalNodes + 1][j] = X[j+1] ***) xx[i_][j_] := X[j] + (i-1)*(X[j+1] - X[j])/(InternalNodes + 1); (*-----------------------------------Which[ InternalNodes != 0, xx[i_][j_] := X[j] + (i-1)*(X[j+1] - X[j])/(InternalNodes + 1), True, xx[i_][j_] := X[j] ](* Close Which *); ---------------------------------------*) (* ------------------------------------------*) (*-------------- LOCAL SHAPE function of node j on element i ----------*) (* ------------------------------------------*)
98
(** *** Each element will has (InternalNodes + 2) NODES. The local shape *** function for a particular element, [j] for example, can be labeled as *** Nlocal[1][j][x], Nlocal[2][j][x],...,Nlocal[InternalNodes + 2][j][x] ***) Nlocal[i_][j_][x_] := Module[{a,b,k}, a = 1; b = 1; Do[ Which[ k != i, a = a*(x-xx[k][j]); b = b*(xx[i][j]-xx[k][j]) ], {k,1,InternalNodes + 2}]; Expand[a/b]]; (* ------------------------------------------*) (*-------------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, 2, 3, ..., N) ** ---*)
99
Nglobal[i_][j_][x_] := Which[ (i == 1 && j != 1), (Hold[Which][ x >= Evaluate[X[j-1]] && x < Evaluate[X[j]], Evaluate[Nlocal[InternalNodes + 2][j-1][x]], x >= Evaluate[X[j]] && x <= Evaluate[X[j+1]], Evaluate[Nlocal[i][j][x]], True, 0 ] /. Hold[Which]->Which), True, (Hold[Which][ x >= Evaluate[X[j]] && x <= Evaluate[X[j+1]], Evaluate[Nlocal[i][j][x]], True, 0] /. Hold[Which]->Which) ](*Close Which *); (* *) (* FORMING GLOBAL SHAPE FUNCTIONS USING GLOBAL NUMERATION OF NODES *) (* --------------------------------------------------------------- *) jj=0; Do[ For[i=1, i<=InternalNodes + 2, i = i + 1, If[ (i == (InternalNodes + 2) && j != (MainNodes-1)), (********* NO GLOBAL FUNCTION FOR THIS NODE ******) (* jj = jj -1 *), jj = jj + 1;
100
nglobal[jj][x_] := Evaluate[Nglobal[i][j][x]]; ]; (* 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 *), {j,1,(MainNodes-1)}](* Close Do *); (* *) (* -------- 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],x]]; Dglobal[i_][j_][x_] = Hold[D[Nglobal[i][j][x],x]]; (* "Load vector" for element k. i is the internal node *) (* --------------------------------------------------- *) (* USER INPUT *) (* ---------- *) Clear[lambda, Q1, Akfunc, A1, alfa1, beta1, A2, alfa2, beta2]; lambda := -1.0; Q1[x_] := -((lambda2)*Exp[lambda*x])/(Exp[lambda]-1.0);
101
Akfunc[x_] := 1.0 ; A1 = -1.; alfa1 = -Exp[lambda] ; beta1 = -(Exp[lambda]-1.0)/lambda; A2 = 0. ; alfa2 = alfa1 ; beta2 = - beta1; Clear[TheBcAtNodeXa, TheBcAtNodeXb]; TheBcAtNodeXa = (alfa1/beta1)*Akfunc[Xa]; TheBcAtNodeXb = (alfa2/beta2)*Akfunc[Xb]; (* Boundary conditions *) (* ------------------- *) Clear[fbcXa, fbcXb, ExactT]; fbcXa = -(A1/beta1)*Akfunc[Xa]; fbcXb = (A2/beta2)*Akfunc[Xb]; ExactT[x_] := (Exp[lambda*x]-1.0)/(Exp[lambda]-1.0); f1[i_][k_] := \ Module[{x}, Integrate[Q1[x]*Nlocal[i][k][x],{x,X[k],X[k+1]}]]; (* Local "Load Vector" Element [i] for element k *) (* --------------------------------------------- *) Do[ Do[ Flocal[i][k] = f1[i][k], {i,1,InternalNodes + 2}] ,{k,1,(MainNodes-1)}];
102
(* Local Matrix Element [i,j] for element k *) (* ---------------------------------------- *) Which[ InternalNodes != 0, K1[i_][j_][k_] := Module[{x}, Integrate[Dlocal[i][k][x]*(Akfunc[x])*Dlocal[j][k][x], {x,X[k],X[k+1]}]], True, K1[i_][j_][k_] := Module[{x}, Integrate[ ReleaseHold[Dlocal[i][k][x]]*Akfunc[x]*ReleaseHold[Dlocal[j][k][x]], {x,X[k],X[k+1]}]] ]; (****-----------------------------------------------------------------****) (****-----------------------------------------------------------------****) Do[ Do[ Do[ Klocal[i,j][k] = ReleaseHold[K1[i][j][k]]; If[j != i, (* Using the fact the K matrix is symmetric *) Klocal[j,i][k] = ReleaseHold[K1[i][j][k]]
103
] ,{j,i,InternalNodes + 2}] ,{i,1,InternalNodes + 2}]; MatrixLocal[k] = Table[ Table[Klocal[i,j][k],{j,1,InternalNodes + 2}], {i,1,InternalNodes + 2}] ,{k,1,(MainNodes-1)}]; (****-----------------------------------------------------------------**** ** ** 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. ** This is necessary because if for example element j is between global ** nodes Nj, Nj+1, ..., Nk the contribution of the local element J to ** global matrix K is as follows: ** ** K[Nj,Nj] = K[Nj,Nj] + KL[1,1] ** K[Nj,Nj+1] = K[Nj,Nj+1] + KL[1,2] ** .... ..... ...... ** K[Nk,Nk] = K[Nk,Nk] + KL[(Nk-Nj)+1,(Nk-Nj)+1] ** ** The drawing belong may be useful to see the this. ** ** Nj Nj+1 Nj+2 .... Nk ** ------------------------------------------------
104
** Nj | KL[1,1] KL[1,2] KL[1,3] .... KL[1,(Nk-Nj)+1] ** Nj+1 | KL[2,2] KL[2,2] KL[2,3] .... KL[2,(Nk-Nj)+1] ** . | . . . . ** . | . . . . ** . | . . . . ** Nk | KL[(Nk-Nj)+1,1] .... KL[(Nk-Nj)+1,(Nk-Nj)+1] ** -----------------------------------------------** ** Now, The total number of (global) nodes is: ** ** TotalGlobalNodes = InternalNodes*NumberOfElements + MainNodes ** = InternalNodes*(MainNodes - 1) + MainNodes ** ** It is not hard to see that element j is found between the ** global nodes: ** ** StartOfElement[j_] := InternalNodes*(j-1) + j ; ** EndOfElement[j_] := StartOfElement[j] + InternalNodes + 1 ; ** ****-----------------------------------------------------------------****) Clear[NumberOfElements, TotalGlobalNodes, TotalElementNodes, StartOfElement, EndOfElement, Kglobal, KcontributionOfElement, FloadContributionOfElement, FLoadGlobal, FloadVector,
105
GlobalMatrixK, Ftotal, Temperature, eqs, eq, eq1]; NumberOfElements = MainNodes - 1 ; TotalGlobalNodes = InternalNodes*NumberOfElements + MainNodes ; TotalElementNodes = InternalNodes + 2; StartOfElement[j_] := InternalNodes*(j-1) + j ; EndOfElement[j_] := StartOfElement[j] + InternalNodes + 1 ; (* Initializing Kglobal and FLoadGlobal to Zero *) (* -------------------------------------------- *) Do[ Do[Kglobal[i,j] = 0.0 ,{j,1,TotalGlobalNodes}], {i,1,TotalGlobalNodes}]; Do[FLoadGlobal[i] = 0.0 ,{i,1,TotalGlobalNodes}]; (* Contribution of Element k to Global Load Vector Fload *) (* ----------------------------------------------------- *) FloadContributionOfElement[k_] := Module[{l,m,i}, i = 0; Do[(* l Do *) i = i + 1; FLoadGlobal[l] = FLoadGlobal[l] + Flocal[i][k]; ,{l,StartOfElement[k],EndOfElement[k]}]];
106
(* Contribution of Element k to Global Matrix K *) (* -------------------------------------------- *) KcontributionOfElement[k_] := Module[{l,m,i,j}, i = 0; Do[(* l Do *) i = i + 1; j = i - 1; Do[(* m Do *) j = j + 1; Kglobal[l,m] = Kglobal[l,m] + Klocal[i,j][k]; If[ m != l, Kglobal[m,l] = Kglobal[l,m]]; ,{m,l,EndOfElement[k]}]; ,{l,StartOfElement[k],EndOfElement[k]}]]; (* Finding Contribution of each Element to Global Matrix K *) (* ------------------------------------------------------- *) Kglobal[1,1] = Kglobal[1,1] - TheBcAtNodeXa; Kglobal[TotalGlobalNodes,TotalGlobalNodes] = Kglobal[TotalGlobalNodes,TotalGlobalNodes] + TheBcAtNodeXb; Do[ KcontributionOfElement[k],{k,1,NumberOfElements}];
107
Print["Global_K_Matrix = ",MatrixForm[ GlobalMatrixK = Table[ Table[Kglobal[i,j],{j,1,TotalGlobalNodes}], {i,1,TotalGlobalNodes}]]]; (* Finding Contribution of each Element to Global Fload *) (* ---------------------------------------------------- *) Do[ FloadContributionOfElement[k],{k,1,NumberOfElements}]; Print["F_Load = ",MatrixForm[ FloadVector = Table[ FLoadGlobal[j],{j,1,TotalGlobalNodes}]]]; (* Boundary conditions *) (* ------------------- *) Print["F_boundary = ",MatrixForm[ Fboundary = Flatten[{fbcXa,Table[0,{i,2,TotalGlobalNodes-1}],fbcXb}]]] ; (* --------------- *) Print["F_total = F_boundary + F_Load = ",MatrixForm[ Ftotal = Fboundary + FloadVector ]]; (* --------------- *) Temperature = Table[T[i],{i,1,TotalGlobalNodes}];
108
(* --------------- *) eq1 = GlobalMatrixK.Temperature - Ftotal ; (* --------------- *) Do[ eq[i] = eq1[[i]] == 0, {i,1,TotalGlobalNodes}]; (* --------------- *) Clear[Tnodes]; Print[" "]; Print[" Tnodes = ", Tnodes = Flatten[ Solve[Table[eq[i] ,{i,1,TotalGlobalNodes}], Table[T[i],{i,1,TotalGlobalNodes}]] ]]; (* --------------- *) Print[" "]; (* --------------- *) Clear[FEsolofT]; FEsolofT[x_] := Sum[nglobal[i][x]*T[i],{i,1,TotalGlobalNodes}] /. Tnodes ; Print[" FEsolofT[x] = ", FEsolofT[x] ]; Print[" ExactT[x] = ", ExactT[x] ]; (* --------------- *) Clear[t1,t2,TITLE];
109
t1=ToString[StringForm[ "Finite Element Solution using 1 Main",MainNodes]]; t2=ToString[StringForm[ " Nodes and 1 Internal Nodes ", InternalNodes]]; TITLE = StringJoin[t1," \n ",t2]; FEplot = Show[Plot[{Evaluate[FEsolofT[x]],Evaluate[ExactT[x]]},{x,Xa,Xb}, PlotRange -> All, AxesLabel -> {"x","Temperature"}, (* PlotLabel -> TITLE, *) PlotStyle -> {{RGBColor[0, 0, 1], AbsoluteThickness[2]}, {RGBColor[1, 0, 0], Dashing[{.02}], AbsoluteThickness[2]} }, PlotLegend -> {"Finite Element Solution", "Exact Solution"}, LegendPosition -> {-1, -1.2}, LegendSize -> {1.7, .5}, DisplayFunction -> Identity ](* close Plot *), Frame -> True, FrameTicks -> False (* no tick marks around the frame *), FrameLabel -> {"", "", TITLE,""}, DisplayFunction -> $DisplayFunction, AxesOrigin -> {0,0}];
110
(* SAVING THE PLOT *) (* --------------- *) Print["\t \t *** Saving Finite Element solution Plot *** "]; MySavingPlot["FEplot.ps", FEplot]; InputString["\t \t \t Hit Return to continue "]; (* --------------- *) CLear[xval, ExactTAtval, FEsolAtval, RelativeError, Ttitles, values, table ]; xval = Table[Random[Real,{Xa,Xb}],{50}]; ExactTAtval = Map[ExactT,xval]; FEsolAtval = Map[FEsolofT,xval]; RelativeError = Abs[(ExactTAtval-FEsolAtval)/ExactTAtval]; (*-------------------------*) pairstoBeplot = MapThread[List,{xval,RelativeError}]; Clear[t1,t2,TITLE]; t1=ToString[StringForm["Relative Error using 1 Main",MainNodes]]; t2=ToString[StringForm["Nodes and 1 Internal Nodes ", InternalNodes]]; TITLE = StringJoin[t1," \n ",t2]; ErrorPlot = Show[ ListPlot[pairstoBeplot, Prolog -> AbsolutePointSize[4], AxesOrigin -> {0,0}, DisplayFunction -> Identity ](* Close ListPlot *), 111 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
Frame -> True, FrameLabel -> {"x", "Abs[(ExatT-FEsolofT)/ExactT]", TITLE,""}, DisplayFunction -> $DisplayFunction, AxesOrigin -> {0,0}]; (* SAVING THE PLOT *) (* --------------- *) Print["\t \t *** Saving Relative Error Plot *** "]; MySavingPlot["ErrorPlot.ps",ErrorPlot]; InputString["\t \t \t Hit Return to continue "]; (* --------------- *) (* Take the comments to print the values in a table *) (* ---------Ttitles = { " x ", " FEsolofT ", " ExactT ", "Rel. Error" }; values = { xval, FEsolAtval, ExactTAtval, RelativeError}; Print[table = RegularForm[TableForm[ MapThread[List, Table[{Part[Ttitles,i],Part[values,i]},{i,1,4}]] ]]]; ---------- *)
At CeCalCULA (http://www.cecalc.ula.ve/) we have available ABAQUS, an engineering simulation software to perform FE computations of
112 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
problems ranging from relatively simple linear analyses to the most challenging nonlinear simulations. The community currently using this software are faculty member of the Universidad de Los Andes and other researchers throughout the country.
113
114
i-1,j
An Introduction to Computational Fluid Dynamics
i,j
115
116
117
Dealing with such difculty is done by using a mapping or transformation from physical ( , , ) space to a generalized curvilinear coordinates ( , , ) space such that a distorted region in physical space is mapped into a rectangular region in the generalized coordinate space (see gure 3, on page 26). The existence of a unique single valued relationship among the coordinates is dened by the Jacobian ( ) of the transformation. That is,
(58)
obtained: ; ;
The elements of
and
(59)
119
; ;
; ;
This equations are useful to evaluate numerically the Jacobian ( ) whenever is necessary based on the generalized coordinate grid. On the other hand, derivatives in the physical ( , , ) coordinates are related to derivatives in the generalized ( , , ) curvilinear coordinates by a relation of the form:
(60)
120
(61)
Complications introduced by the use of generalized coordinates include to nd the form of the governing equations in the generalized coordinates. For example, Laplaces equation in two dimensional ( , ) physical coordinates has the form:
(62)
121
122
and
if in addition the transformation is conformal, then the and ) applies given Cauchy-Riemann conditions ( and equation 65 becomes:
which is an equation structurally no more complex than the one in ( , ) physical coordinates, equation 62. When an analytical mapping between the ( , , ) physical coordinates and the ( , , ) curvilinear coordinates is not available, the transformation parameters , , , and so on, must be computed
(66)
123
numerically, usually using the same discretization scheme as the one used to discretize the derivative terms in the governing equations. That is, if the latter are discretized using a nite difference scheme, the former are discretized using the same corresponding formulae. For instance, if working with a centered nite discretization scheme, in 2D one could have:
124
recall that the governing equations are discretized in the ( , ) domain,
(67)
125
which usually corresponds to a uniform rectangular grid. The inverse parameters ( , , etc.) are then obtained by means of relations 60, on page 119.
6.1
Assuming the grid in the physical domain does not change with time, the Continuity Equation Fletcher, vol. 2, pages 64-69 gives general formulae for transforming rst and second two dimensional general partial differential equations to generalized ( , ) coordinates. He then goes on and applies the formulae to uid ow equations, obtaining for the continuity
126
while for the x-momentum equation of incompressible viscous ow, expressed in nondimensional form, he obtains: (69a) (69b)
127
in and in the last set of equations Lets mention that terms like could introduce an error if signicant grid stretching is permitted, leading to a reduction in the accuracy of the computed solution. In the case of high ow problems, however, this terms does not usually have a large effect. The implementation of generalized nite difference schemes is not more difcult than the implementation of the nite volume method and produces solutions of comparable accuracy.
128
(69c)
(69d)
Closure
Let me rst thanks very much to any one of you for being a participant of this Workshop. 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. However, it is my hope to have keep, or even better increase, your motivation on this wonderful eld, so you can go ahead and start a carefully reading of many of good sources on CFD, a few of them are included in the reference section. In there you will nd precise pointers to the various tools available to assist you with the numerical solution of a wide range of mathematical problems. These tools are widely available on nearly all computer platforms.
129
7.1
In addition to the references listed at the end of this document and to the online CFD examples listed on section 2.4.1, 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.cfdonline.com/ Online CFD Books: http://www.eng.warwick.ac.uk/staff/cts/cfdbook/ http://www.crs4.it/HTML/int book/NumericalMethods/int book.html http://www.rzg.mpg.de/ bds/numerics/cfdlectures.html http://people.nas.nasa.gov/ pulliam/mypapers/vki notes/vki notes.html
130
http://wwwdinma.univ.trieste.it/ nirftc/research/easymesh/easymesh.html Books with web sites: Wesseling, P. (2000). Principles of Computational Fluid Dynamics, Springer. http://dutita0.twi.tudelft.nl/nw/users/wesseling/cfdbook.html Ferziger, J. H. & Peric, M. (1999). Computational Methods for Fluid Dynamics, Springer. ftp://ftp.springer.de/pub/technik/peric/ Pozrikidis, C. (1997). Introduction to Theoretical and Computational Fluid Dynamics, Oxford. http://stokes.ucsd.edu/pozrikidis/TCFD/
131 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
References
[1] Batchelor, G. K. (1967), An introduction to uid dynamics, Cambridge Univ. Press. [2] Fletcher, C. A. J. (1991), Computational techniques for uid dynamics, 2nd ed., vol. 1 & 2, Springer-Verlag. [3] Ganzha, V. G. & Vorozhtsov, E. V. (1996), Numerical solutions for partial differential equations, CRC Press. [4] Gerald, C. F. & Wheatley , P. O. (1994), Applied numerical analysis, 5th ed., Wesley. [5] Ottosen, N. S. & Peterson, H. (1992), Introduction to the nite element method, Prentice Hall. [6] Press, W. H. et al. (1992), Numerical recipes in fortran, 2nd ed., Cambridge University Press. [7] Reddy, J. N. (1984), An introduction to the nite element method, McGraw-Hill. [8] Sokolnikoff, I. S. (1964), Tensor analysis: Theory and applications to geometry and mechanics of continua, Wiley.
132 Sergio Rojas: http://www.cecalc.ula.ve/ sergio/
[9] Zienkiewicz, O. C. & Taylor, R. L. (1989), The nite element method, 4th ed., vol. 1 & 2, McGraw-Hill.
133