Computational Fluid Dynamics Prof. Dr. Suman Chakraborty Department of Mechanical Engineering Indian Institute of Technology, Kharagpur
Computational Fluid Dynamics Prof. Dr. Suman Chakraborty Department of Mechanical Engineering Indian Institute of Technology, Kharagpur
Lecture No. # 10
Fundamentals of Discretization: Finite Element Method
Now, if we if one follow this particular procedure then the overall analysis can be
thought of as a collection of the following; one is pre-processing, another is solution and
the third one is post-processing. These are the broad steps in the overall analysis. So, in
pre-processing, what you are doing? You are setting of the problem. So, how do you
setup the problem? You setup the geometry and discretized equations, input data that
means property data as an example, initial condition, boundary condition, etcetera. So,
these are the inputs which are necessary. And once this thing is properly setup then you
basically required to solve algebraic equations. Once this algebraic equations are solved
you get the value of the variable, say temperature or velocity at each and every point, and
then post-processing is a graphical representation of the obtained results.
No matter whatever numerical method we are adopting, the method will go through these
steps, so long as we are solving the problem in a continuum perspective. We will take up
some examples of numerical methods which illustrate these principles, and the first
example that we take up is the finite element method. So, let us consider the finite
element method; we considered it first, because it evolves from the variational
formulation that we have considered in some of our previous lectures.
(Refer Slide Time: 06:07)
So, finite element method finite element method or FEM. Of course, we can go deeper
and deeper in to the method, but we have to keep in mind that this is not a course totally
dedicated towards finite volume finite element method. So, our objective will not be to
go into the details of this method, but may be take up a generic simple example to
illustrate the use of this method in perspective of the discretization policy - that we have
just formulated. So, let us take an example and we will learn this method or the basics of
this method through this example.
So example, say you are solving a one-dimensional steady state heat conduction
equation. See we have considered this as a prototype equation for illustrating many of the
principles, and let us say that we do it for illustrating the finite element method itself.
Remember that the finite element method can be perceived in many ways, but in one of
the ways in which it can be done is that one type of finite element method can be thought
of as a discrete version of the Galerkin’s method. So, the Galerkin’s method if you recall
that we had a trial function same as the weighting function, and we employed that trial
function and weighting function over the entire domain.
Now, in the discretized version of that in the finite element method, we will employ that
over each of the discrete sub domains in which the domain is decomposed, and each sub
domain is called as an element in a finite element method. So, the first step if you
remember, divide the domain into a number of discrete sub domains. So, if it is a two-
dimensional or three-dimensional problem you could have sub domains of different
shapes, may be in this way we can go on; this is a one-dimensional problem. So, here the
sub domains are nothing but straight lines. So, you have this as a total domain. Let us say
that this, the left hand side is x equal to 0, right hand side is x equal to L. And let us say
that the boundary conditions are as follows; that it is insulated at x equal to 0 and
temperature is specified at x equal to L.
See we have not yet formally discussed about the different types of boundary conditions.
It is very, very important to discuss about that and how to implement that in a generic
situation, and we will come in to that issue subsequently. But right now at least these
types of boundary conditions we have we can demarcate as either the essential or the
natural boundary conditions, which are very much defeating with the variational
formulation. Now, we are interested to solve the temperature distribution within this
domain. Let us say this is a rod, physically the rod is such that its cross sectional area is
much smaller than its corresponding axial length, and major temperature variation takes
place axially. There is some uniform heat source that is present which is given by this S.
Now, we divide the domain in to a number of sub domains. So, let us say that we divide
it in to three sub domains. So, sub domain number 1, sub domain number 2, sub domain
number 3; each sub domain we call as element. So, we have element number 1, element
number 2, element number 3; each element in turn is represented by some discrete points
- sets of points. So, these discrete set sets of points in the terminology of finite element,
these are called as nodes. So, we give the node numbers 1, 2, 3, 4 like that. So, we can
create a chart of element node connectivity. Remember that it is it not necessary that
each element will have two nodes; each element can have whatever number of nodes,
and we will see very soon that more the number of nodes contain by each element, you
have higher and higher order approximating polynomial that can be that can be used for
interpolating the dependent variable within the element. But obliviously more and more
number of nodes will mean that you have higher computational expense, because you
have to solve for the variable at those nodes. So, there is a sort of compromise that one
looks for.
Now, you can prepare a chart where for each element, you can identify the nodes. So, for
element number 1 the first node is 1, the second node is 2; for a element number 2 first
node is 2, second node is 3; for element number 4 3 first node is 3 and second node is 4;
and each node is having its own coordinate. So, you can use whatever coordinate system
you want to specify the coordinate of each node. It is a one-dimensional problem. So,
although I have given a comma that is not necessary, you just require one coordinate -
one x-coordinate, but if it were a two-dimensional problem, it could have been x comma
y that is why I have put a comma or may be a three-dimensional problem a third
coordinate. But here this comma is not necessary you just have only one coordinate
specifying the the location of the point. So, this is a chart which is important, which is
like an element node chart, which relates the connectivity of each element with the
corresponding nodes.
Now, what we will do is, we will consider any isolated element. Let us say that we
consider an element this one where the first node is i and the second node is j. So, we
have one element which is starting with node i, ending with node j, and we are interested
to write, at algebraic equation corresponding to this governing differential equation for
that generic element; that is our objective. Let us say that the name of the element is e.
So, what we will do? We will start with the basic principle of the Galerkin’s method. So,
the first step will be to multiply the governing differential equation with a weighting
function, and then integrating it, not now over the whole domain, but over each sub
domain that is over each element, and then some that effect up over all the elements. So,
effectively you are using the Galerkin’s method over the entire domain, but it is a
discrete summation rather than a continuous integration over the entire domain. So, first
you consider the Galerkin’s method implemented over each sub domain then you sum it
up over all the sub domain. So that you get the net effect over each over the total domain,
but in a discrete sense, not no more in a continuous sense.
(Refer Slide Time: 14:26)
Now, the change from the variational formulation is that it will be no more from 0 to L,
but from x i to x j and then this is summed up over all element that is the conceptual
difference. So, what we will do is, we will consider first the formulation for each element
and then we will sum it up or assemble it up later on. So, it will be from i to j, x i to x j, x
i to x j. So, the first difference you follow from the general variational formulation. Then
what we will do? We have to now assume a trial function and a weighting function. See
we have reduced the order of the continuity requirement of the trial function by doing the
integration by parts. So, the highest order derivative that you require is dT dx. So, linear
function of T as a function of x we will do, and a linear function will require two
coefficients for its specification.
So, if you have a two nodded element which we sketched in our figure with each element
has node i and j, then that would be sufficient. But if that was not the case, then you
would have required a higher order derivative to specify. Next what you do? We will try
to write the corresponding trial and weight function in this particular expression. So, the
trial function, so you have two node points where you where you can specify the
variable. So, you can have a trail function T is equal to a 0 plus a 1 x. This is a trial
function. Remember the trial function you are making valid within each element, not a
global trail function, but a trail function that is valid over individual elements. So, it is a
piecewise linear interpolation that you are considering (( )) to say, it is not a global single
linear interpolation.
Now, you have the following information that at x equal to x i, you have T equal to T i.
Which is an unknown? Which you intend to find out? An at x equal to x j, you have T
equal to T j. So, it is physically must more much more interesting and intuitive, if you
express a 0 and a 1 in terms of T i and T j. Because those are the unknowns that you need
to solve, and those directly relate to the physical variable that you are interested in. So,
we can write T i is equal to a 0 plus a 1 x i, and T j is equal to a 0 plus a 1 x j . So, now
you can find out a 0 and a1. So for example, a 1 if you subtract this two a 1 into x j
minus x i is equal to T j minus T i which means a 1 is T j minus T i by x j minus x i. And
you can find out a 0 from anyone of the equations, say the first equation, it is T i minus a
1 x i, so T i minus T j minus T i by x j minus x i into x i. So, a 0 will be T i x j, minus T i
x i and plus T i x i will cancel, so minus T j x i by x j minus x i.
Interestingly you can see one very important property of this shape function. What is the
property? What is the value of N i? See these functions are defined at discrete points i
and j; N i equal to what at node i. At node i, x equal to x i, so N i equal to 1 at node i, and
what is it at node j? It is 0 at node j, because it will become x j minus x j, 0 at node j. So,
in general N i equal to 1 at at the node i and 0 at other nodes. That is the property of a
shape function.
(Refer Slide Time: 23:56)
Now, what we will do is, so this is a trial function. So, you can write this particular
expression T equal to N i T i plus N j T j in a matrix form; how, you can write this as N i
N j T i T j. The objective of this is eventually your unknown that you need to solve may
be written in a vector T i and T j, which you need to solve for each node point. So, this
we give a name matrix N and this we give a name matrix T. Now, question is what is the
weight function? In the Galerkin’s method, the trial function and the weight function
have the same form. So that you can write as N into W, where what is this W? W is W i
and W j; conceptually they are like delta T i and delta T j. Since W is a scalar, this is
same as W transpose; it is just a scalar, transpose of the scalar is scalar itself. So that is
same as W transpose N transpose, because a into b transpose is b transpose into a
transpose.
(Refer Slide Time: 26:15)
So, with that in mind let us try to write the corresponding form of this equation. So, in
place of w, we will write W transpose into N transpose in place of k dT dx; see what is k
dT dx? Minus k dT dx is the heat flux. So, k dT dx specification of that is basically a
natural boundary condition specification. So, we will honor that concept in mind, and
then instead of k dT dx we will write this as minus of the heat flux, where q double
prime is the heat flux which is equal to minus k dT dx by Fourier’s law of heat
conduction. This entire thing should be evaluated between i and j. Then minus dw dx,
see if you that differentiating this with respect to x, remember x is contain within N only.
So, you can write this as W transpose then integral of dN dx transpose into k into dT dx
is N transpose dN dx into T dx. So, we have substituted dT dx as dN dx into T;
remember this T does not contain x, these are the just the nodal values. Plus integral of
now W transpose then integral of S, in place of W it is W transpose N transpose.
(Refer Slide Time: 28:17)
Now, since W transpose is arbitrary, it is just a variation. You are left with minus of N
transpose q between i to j minus dN dN dx transpose k dN dx, whole thing multiplied
with T, plus integral of S N transpose dx equal to 0. We will simplify this one by one.
So, first consider this expression; minus N transpose means what? So, we are first
considering this term, say term 1; minus N transpose means N i N j corresponding q then
this entire thing between i and j. So, first you evaluate this quantity at j then subtract the
same quantity at i. This is the upper limit minus the lower limit. So, what is the quantity
at j? N i equal to what at j? 0, and N j is equal to 1 at j. So, it will be minus 0. So, one
times the heat flux at j. This is the upper limit. Then the lower limit N i equal to 1 at 1 at
i. So, q double prime i and this is 0. So, it is minus q double prime i sorry plus q double
prime i and minus q double prime j.
Then let us consider the term two excluding the minus sign, so term 2. Term 2 integral i
to j dN dx transpose. What is dN dx? dN i dx dN j dx. So, what is… So, let us write that
dN i dx dN j dx, k is there, then dN i dx dN j dx.
Term 2 exclude the T also, this is the unknown vector that you have to find out. So, we
are excluding that from the evaluation of the term. So, what is dN i dx? So, dN i dx is
minus 1 by x j minus x i and dN j dx is 1 by x j minus x i; x j minus x i is nothing but the
length of each element. The difference between the x coordinates of the two ends. So,
this is minus 1 by l e, this is 1 by l e. So, let us consider that for the integration.
So, this will become k by l e, 1, minus 1, minus 1, 1; 1 l e will come additionally integral
of dx from i to j will be l e, so that l e will cancel with l e square to make 1 by l e. So,
this is the term 2.
And term 3, let us consider this as the term 3; S is a constant then integral of i to j N
transpose dx; so x j minus x by l e and x minus x i by l e, this is d x. So, you can do the
integration like for the first case you can substitute x j minus x equal to a new variable.
So, then this will be that new variable, let us say that new variable is y. So, it will be of
the form integral of y dy from 0 to l e. So, it will be l e square by 2; that l e square by 2
divided by this l e will be l e by 2. So, this will be S l e by 2 and S l e by 2.
See this is the common sense appear. You have the total heat source as S in to l e, and
that is dumped in the two nodes. Because if you see that eventually the entire effect of
the element is manifested by the behavior of the nodes. The nodes have the sole
responsibility of taking care of the burden of representing the behavior of the element.
So, whatever is the total that is now apportioned between the nodes. So, because there is
no bias or asymmetry between the nodes, it is just 50-50 share. So, it is a common sense
thing even without doing the integration you can see, but of course by doing the
integration you can exactly verify that. Now, let us assemble this equation.
(Refer Slide Time: 36:42)
So, what is our equation? Our equation is term 1 or rather let us write term 2, take it in
one side, term 2 into T is equal to term 1 plus term 3. So, k by l e 1, minus 1, minus 1, 1,
T i T j is equal to… This is what you write for each element. Now, similar thing you
can… So, this is what you write for each element means just your i and j will be
different. So, for the first element i will be 1, j will be 2. So, let us reconstruct that sketch
of the elements. You had three elements, so 1, 2, 3, 4; this was insulated and this is T
equal to T L. So, for the first element i will be 1, j will be 2; for the second element i will
be 2, j will be 3; for the third element i will be 3, j will be 4. So, you can write similar
equations - similar three equations for each of the three elements. Question is now, how
to assemble it globally? So that you get the behavior of the summation of all the
elements or all the elements connected together.
Now, there are certain important things that you can observe from here. One is that for
each element you are getting a 2 by 2 matrix. So, this sometimes is the left hand side is
of such a form that you can write it as K into T where is capital K is different from this
thermal conductivity, so let us say K bar, K bar into T equal to some F. This is the
hallmark of a linear system; just like a linear spring mass system, you have K x equal to
F, where K is the stiffness of the spring. Here similarly this is playing an artificial role of
a stiffness. As if you are abstracting the physics from the mathematics. So, because of
the mathematical analogy, this appears to be as if this is like a stiffness of the system.
This is the as if the displacement.
So, here the stiffness the role of the stiffness is being played by k by l e which is like the
thermal conductance, and these are like the displacements and these are like forces. So,
the source term and the heat flux is like a force which is acting on the system. So, it is
almost like a spring mass system. And why this analogy with the spring mass system one
always gives, because the finite element method was originally developed for structural
mechanics by engineers. It was not originally developed for solving heat transfer and
fluid flow problems. So, still this type of matrix is known as a stiffness matrix. But we
can we need to keep in mind that it is just a nomenclature, it has nothing to do with the
stiffness in a heat transfer problem, the heat transfer problem in the physics; of course,
has nothing to do here with the stiffness.
Now, if we need to assemble so and if you get a 2 by 2 equation for each element, then
when it is summed up over all the elements what will be the size of the total matrix that
we will get. So, if it is for if for 2 nodes it is 2 by 2, then for 4 nodes it must be 4 by 4.
So, what we can see here is that we will get a square matrix as a coefficient matrix; so 4
by 4.
So, we just indicate the number of rows and columns by 1 2 3 4 and 1 2 3 4, just for our
own convenience. So, what we are trying now? So, this is the local formulation; we are
now trying to globalize it and assemble. So, assembly in the form of a global matrix that
is what we are attempting. What are our unknowns? Unknowns are T 1 T 2 T 3 T 4, and
right hand side you have a heat flux term and you have a heat source term. So, we need
to… So, we have prepared the structure of the matrix form. Now, we have to put in or
plug in the numbers. First for the element number 1, what are the node points which are
involved with the element number 1? 1 and 2. So, it is…
This part of the coefficient matrix that will be activated. So, what will be the
corresponding entries? Let us put the entries here. So, what will be the entry
corresponding to 1? That is 1, then entry corresponding to 2 - minus 1. So, as if you are
just copying that from the local matrix; minus 1 and this as 1. Right hand side, this is q 1,
then this is minus q 2; then this is S l e, this is half and this is half. Then for the next
element - 2 and 3 right; so, what what will be the activated part? 2 and 3 both from the
row and the column side, so this will be the corresponding active part of the global
matrix. So, you have 2 and 3 and here you also you have 2 and 3. Again it will be 1, so
you have… Remember you are just linearly adding, because it is a summation - algebraic
summation, you are summing it up over all elements; so 1, minus 1, minus 1 and 1.
Similarly, so remember for the first case it was like this, for the second case it is this one
and… Let us complete the right hand side. So, for the right hand you have this as so here
you have plus q 2 double prime, you have minus q 3 double prime, here you have plus
half and here you have half. Then finally, you have this dotted portion 3 and 4, so 1,
minus 1, minus 1, 1. Here plus q 3 and minus q 4; plus half and half. What is an
important assumption that we have made? We have made an important assumption that k
is a constant that is the thermal conductivity is a constant, it does not vary from one
element to the other. But if it is a composite material, then it is possible that different
elements have different thermal conductivities that is what we are not consider. And the
other simplification is that we have considered each element to be of same length. That is
not necessary, but just for algebraic simplification we have put in put it; otherwise
different elements will have different length.
So, if you assemble this let us write the final form. So, 1, minus 1, minus 1, 2, minus 1,
minus 1, 2, minus 1, minus 1, l, the remaining ones are zeros. Now, you can complete the
problem by imposing the boundary conditions. What are the boundary condition that we
are given? At x equal to 0 the heat flux is 0, it is insulated. So, this is 0, this is one
boundary condition, and at 4, T 4 is specified. So, since T 4 is specified solution of that
is not necessary. But let us say you are using a computer program which does not know
that T 4 is specified, but it still intense to solve, despite the fact that it is specified. So,
you can understand the problem, the problem is like this. You will be solving T 1 no
doubt about it, you will be solving T 2, T 3 no doubt about it, but you will you do not
want to solve T 4, because T 4 is already specified. But say every time you do not want
to change your computer program to tune it with the fact that which is specified and
which is not specified. So, even though T 4 is specified, you may want to solve for T 4
and find out the value exactly same as what is specified, then that will also solve the
purpose.
Then you can use the same structure for solving the equation - system of equations, no
matter whether T 1 is specified or T 4 is specified. So, how we can do that? So, the final
equation for T 4 is like this k 11 T 1 sorry k 41 T 1 plus k 42 T 2 plus k 43 T 3 plus k 44
T 4 is equal to something some right hand side R. And let us say the value of the T 4 is
specified as T 4 star. So, we will play a small trick with this one. What we will do? We
will replace k 41 sorry k 44, because T 4 is specified sorry k 41 remains as it is. We will
replace k 44 by that plus a large number, where L is a large number. And we will replace
R with k 44 in to T 4 star sorry large number in to T 4 star not k 4 the same large
number. We have to see how large it is. Whenever we say large or small, it is of course
from a computational perspective (( )) it is a computational trick. So, what it will do?
So, how can you solve for T 4 from here? Say you divide all the terms by k 44 plus L.
So, it is k 41 minus k 41 by k 44 plus L T 1 minus k 42 by k 44 plus L T 2 minus k 43 by
k 44 plus L T 3 plus L T 4 star by k 44 plus L. So, what you want? You want the larger
numbers to be so large that it is much, much larger in comparison to all the individual k
41, k 42, k 43, like that. So, when you do that this term will be very close to 0. So,
largeness or smallness depends on the values of the individual numbers. So, you do not
have a universal rule for that. Depending on the individual entries of k, you must keep it
much, much larger in comparison to that. So, then this will also be closed to 0, this will
be closed to 0 and this ratio will be approximately 1; k 44 is negligible in comparison to
L. So that means if you solve it you will get T 4 equal to T 4 star numerically. This
approach is known as penalty approach. That is wherever a value is given still if you
want to solve it from the system of algebraic equations, then what is the approach that
you could follow.
Of course, if you are doing it manually, you can get rid of the problem by not solving
that equation itself. But if you are not doing it manually and if you are doing it through a
computer program then may be some other point temperature is also specified. So, you
need to jumble up with the system of equations and manipulate manually, which you can
avoid by making its structured in a way that you can apply it no matter which point at
which point temperature is specified and at which point it is not.
So, to sum it up what what we have achieved by this time? We could convert the
governing differential equation into a system of algebraic equation. The system of
algebraic equation is in the form of K T equal to F where the T includes the temperature
at the unknown points. So, the next problem boils down to the solution of the system of
algebraic equation. So, once you solve the system of algebraic equations you get the
values of temperatures at the discrete points. You no more get a continuous variation, but
what you can always do is, you if you take the points sufficiently close to each other, you
will get a very close variation. So that it will be approximately like a continuous
variation; it will be discrete points joint together through some interpolation. But if there
are sufficient number of points it will look like almost a continuous variation. So, one of
the important things that remains of course is how to solve this system of algebraic
equations. We will consider it or take it up in a through a separate chapter, not through
this particular chapter.
So, in the next class what we will do is, so we have seen that how to come up with the
system of algebraic equations from a vibrational formulation. Next class we will see that
how to come up with the system of algebraic equation through discretization directly
from the deformulation that is a differential equation formulation. And we will take up
an example as a finite difference method which tries to do that. Then what will do is, we
will try to search for some method which sort of is the compromise or something in
between in terms of its behavior, in terms of the finite element method and the finite
difference method, and that method which we will extensively follow throughout this
course is the finite volume method. And the finite volume method we will see that in the
limiting cases, it can be shown as a particular variant of the Galerkin’s weighted residual
method.
But it may also be it it may also be perceived as a control volume based finite difference
method. So, there are different perspectives in which it can be looked at. But our
important objective will not be initially to to detail the finite element, finite difference
and the finite volume method. But to understand that basic essential elements, see their
important features, and once we learn this basic methods we will go deeper and deeper
into the finite volume method for solving the fluid dynamics problems computationally.
That aspect we will take up through a subsequent lectures, but in our next lecture we will
be starting with the finite difference method. See philosophically, how it how it differs
from the finite element method. And then we will identify some plus and minus points of
the finite element and the finite difference method, which will motivate us towards
approaching for the looking for alternative method in terms of the finite volume method.
Thank you.